Where are the local, global, static, auto, register, extern, const, and volatile variables stored?

local variables can be stored either on the stack or in a data segment depending on whether they are auto or static. (if neither auto or static is explicitly specified, auto is assumed) global variables are stored in a data segment (unless the compiler can optimize them away, see const) and have visibility from the … Read more

Variable scope and Try Catch in python

What’s wrong with the “else” clause ? for filename in files: try: im = Image.open(os.path.join(dirname,filename)) except IOError, e: print “error opening file :: %s : %s” % (os.path.join(dirname,filename), e) else: print im.size Now since you’re in a loop, you can also use a “continue” statement: for filename in files: try: im = Image.open(os.path.join(dirname,filename)) except IOError, … Read more

declaring variables without any data type in c

What you see here is the “Implicit Int Rule” at work. Simply put the rule says: “A variable declared without an explicit type name is assumed to be of type int.” Note that this rule was revoked in the c99 Standard[Ref 1].However, depending on your compiler and its settings, the first example might compile with … Read more

What are the magic $-prefixed variables in Ruby? [closed]

Their name is global variables. There are several different references. You can get a full list by calling the method Kernel#global_variables puts global_variables Ruby also includes a file called “English.rb” in the standard library which provides an in-depth explanation of several global variables. Also, there’s (an archived version of) “Cryptic Ruby Global Variables and Their … Read more

Using variables in a vim shell command

Use the execute command. Everything after it is an expression that evaluates to a string, which it then executes like a command you had typed in yourself. function Ls(dir) execute ‘!ls ‘ . a:dir endfunction This says, “Evaluate the expression ‘!ls ‘ . a:dir and then execute it.” The variable a:dir is expanded, the dot … Read more

In Javascript, can I use a variable before it is declared?

This is a technique used by the JavaScript engine called hoisting. The parser will read through the entire function before running it, and any variable declarations (i.e. using the var keyword) will be executed as if they were at the top of the containing scope. So your code behaves like: var country; var i; country … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)