Class 4: C Storage Class, Scope Linkage Flashcards
Storage Class
Determines the type of storage and lifetime of storage associated with a variable and the variables initialization if any
Storage scope
Determines which region of a program in which a variable can be accessed (by name and not through pointer)
Linkage
Determines whether the same name in a different file frees to the same variables or function or some different variable function
Stack
- A place in memory where information specific to particular function is stored each time it is invoked
- It is allocated when the function is called a deal located when he function returns
Heap
- A place in memory where information specific to a particular process is stored each time it is invoked
- Any valuesstored here are available until the process stops executing
Storage class
Refers to the type of memory in which a variable values is stored which defines different characteristics for variable
Static (keyword)
The heap
Automatic (keyword)
The runtime stack
Register (keyword)
Hardware registers
Do function identifiers have a storage class?
NO, they are not stored on the stack or the heap
Storage Class: Static
Declared outside all blocks.
Retain the last value they were assigned until the program completes
What value are storage class static variables automatically assigned to?
0
Storage Class: Automatic
Declared inside a block.
When are automatic variables created
Just before the execution of the code
When are automatic variables discarded
When they are not longer accessible/ just as execution leaves the block
What storage class do parameters of functions have????
AUTOMATIC
Variable declared inside a block but with the keyword static
This changes storage class from automatic (the default) to static. Although this changes show long the variable exists during the program, IT DOES NOT CHANGE THE SCOPE STILL BLOCK SCOPE
When keyword static is used within a block, it changes a variables ______
Storage class
When the keyword static is used outside of any/all blocks, it changes an identifiers ________
Linkage
Register variables
Stored in machines hardware registers rather than memory. Can be accessed faster. Created and destroyed at the same time as automatic variables
Scope
Refers to the point in a program in which an identifier may be used to access a variable directly (not through pointer)
Block scope
Variable can only be accessed within that block
File scope
Declared outside fo all blocks. The identifier can be accessed anywhere from the end of its declaration to end of the source file in which it was declared
Prototype scope
Only applies to parameter names DOES not apply to function names