Pointers
How do you put the value of 10 into a variable called target?
#include <stdio.h> int main(void) { int target, source=10; int *m; m = &source; target = *m; printf("%d", target); return 0; }
Many registers are required from system use and can't be allocated otherwise:
-Based Address of program -Return Address after program execution ends -Instruction reg, program counter
Extern variables are initialized to _____automatically.
0
What are the Steps of Call by Reference?
1. Declare a function parameter to be a pointer 2. Pass an address as an argument when the function is called 3. Use the dereferenced pointer ( * ) in the function body to reference the argument in the calling function.
When the block is suspended, such as when it calls another function, a variable can still be ___________.
Accessed and changed; if it is used as an actual argument in a function call
When the block becomes active again, the auto variable becomes ______ and can directly reference it by name.
Active
In dynamic memory you are able to _________ values from existing memory while the program is running.
Add/remove
What two operations are allowed in Pointer Arithmetic?
Addition and subtraction
What kind of pointer operator is &?
Address Operator
In register you can't use the __________ .
Address operator or indirection operator ( * ); it is it recommended that you should not use it
Call by Reference is passing a ______ of the argument to a formal parameter which is a ____ of the same type as the argument.
Address, Pointer
Programmers use Volatile objects in ___________.
Advanced systems programming (beyond our scope)
You can use a pointer variable on the right-hand side of ______________ to assign its value to another pointer.
An assignment statement
Compilation unit is ________.
Another file with code in it.
If register is not available it defaults to _______.
Auto
_______ is the most common of the four storage classes.
Auto Variable
Variables declared within function bodies are __________.
Auto Variables by default
_________ are usually not initialized by the system.
Auto and Register
What are the four types of Storage Classes?
Auto, Extern, Register, Static
Points provide support for dynamic data structures, such as _______________.
Binary trees and linked lists
Register variables are in the _______.
CPU
Arguments are in the _________.
Called function
Global Static Variables can be referred to from other ____________.
Compilation units
What are the two Type Qualifiers?
Const and volatile
What kind of pointer operator is * ?
Dereference Operator
Pointers support ____________.
Dynamic memory allocation
All variables defined outside the block are ________ by default.
Extern
___________ variables are dangerous and should be use with caution.
Extern
_________ variables are initialized to 0 be the system.
Extern and Static
Temoral Limitation (Immortal): _________ exists the whole life of the program. From the time of its allocation until the end of the program.
Extern variabels
True/False In Pointer Arithmetic you can add two pointers
False
True/False The storage class auto can only be used in a block: it can be used at a global level.
False; Auto variables cannot be used at a global level
True/False A static extern variable can be called.
False; it cannot be called
True/False Typically the compiler has many registers available.
False; the complier only has few such registers available
Extern must be defined in _____________.
Global area of a program; outside any block
q = *m This means?
Go get the value of m and store the value in q
Call by Reference with Auto Parameters has to be in the ________.
Heading
Register variables so declared should be stored in ____________.
High speed memory
Both & and * and ________ than all other arithmetic operators except the unary minus, with which they share equal precedence.
Higher precedence
Storage Class determines ____________.
How the compiler allocates memory to that variable
Type Qualifiers control ______________.
How variables may be accessed or modified
Temporal Limitation (extent) of Global Static Variable is _________.
Immortal, it lives as global variables live
Temporal Limitation (extent) of Local Static Variables is ________.
Immortal; it lives as if it were a global variable
A static variable can be defined ___________.
Inside a block (local) or in the global areea of the program
If storage class is present and type is absent while using register get ____.
Int
Auto variables provide an effective way to ___________ from the others.
Isolate the actions of each program unit
A function can be Static: The scope of the function is ___________.
Limited to one file only (privacy concern). It is known throughout the entire file
Spatial Limitation (scope): The auto variable is _______, limited to the block in which it is defined and its sub-blocks.
Local
A static variabel that is defined inside a block is called a ________.
Local Static Variable
The spatial Limitation of a local static variable is _______.
Local, undefined outside the block
Extern's primary purpose is to _________________.
Make variables visible to other compilation units
Auto variables is the default SC for local vars because it ___________.
Makes the most efficient use of memory
The modifier volatile tells the compiler that a variable's value _______________.
May be changed in some unspecified way be the hardware.
Pointer Arithmetic cannot __________.
Multiply or divide pointers
A pointer variable has a ______ and a _____.
Name, type
The static local variable will be automatically initialized to 0 when allocated. _________
Once
Extern can be referred to and changed by all blocks that come after it as well as by _____________.
Other programs that are aware of its existence.
A ______ is the memory address of an object.
Pointer
Auto variable can still be referenced and changed through a _______ to it.
Pointer
m = &count; What is m?
Pointer
A _________ pointer variable is a variable that is specifically declared to hold a pointer to an object of its specific type.
Pointer variable
Call by reference requires __________.
Pointers
A Declaration is a program element that ______________.
Provides a compiler with essential information or useful advice
The compiler is free to place const variables into __________.
Read-only memory (ROM)
If you reenter the block auto variable is _________.
Reallocated
Static Local Variables allow a local variable to retain its previous value when a block is _______.
Reentered
type *name; is a _______
Reference operator
________ is an attempt to improve execution speed.
Registers
* is a unary operator that _____________ that follows.
Returns the value located at the address
Temporal Limitation (extent): Are alive only when the block in which they are defined is ________. Variable does ___________, when block terminates it dies.
Running, not exist before block
Static Extern Variable is restricted in _______ to the remainder of the file in which they are defined.
Scope; They're not known in other files (compilation units)
Global Static Variable guarantees that the scope does not extend beyond its __________.
Spatial area, the current compilation unit
Locally defined _______ variables are one of the truly significant features of the "C" language.
Static
To prevent a global variable from being exported to the LINKER from reference other compilation units it can be declared _______.
Static
When both pointers are the same type, the situation is _________.
Straightforward
m = &count; m receives ________.
The address of count
Spatial Limiatation (global): It is visible from its definition to ______________.
The end of the program
Good programmers use Auto variables when ever posssible because _____________.
Their lifetime is brief and their scope is limited to one function
True/False Call by Reference allows you to swap values
True
True/False Pointers can modify arguments in the calling function.
True
True/False Variables of type const may not be changed by your program.
True
True/False you cannot add or subtract type float or double to or from pointers.
True
Every variable or function in C has 2 attributes: __________ and _________.
Type and Storage Class
It is easy to debug large programs in Auto because ____________.
Unintentional interference between functions is minimized
When you specify the type of a variable or parameter you are said to declare ____________.
Variable or parameter
Spatial Limitation (scope) of Global Static Variables is ___________.
Visible from its definition to the end of the compile unit.
Temporal Authority defines _______ an object is available. The extent to which it exists.
When
Spatial Territory defines ______ it can be referred to in the program. Its Scope or Visibility
Where
A ______ is only allowed in a pointer variable.
address
Code within the function can change the value of the ______________.
argument passed to the function
Type Qualifiers are used in declations and must be _____________, but precede the type names that they qualify.
coded after the storage class
Which is correct? int *p=&a; const int *p=&a;
const int *p=&a;
What is Dynamic Memory
create a dynamic sized function
Pointers provide the means by which ____________ in the calling function.
function can modify arguments
int *m; The variable m can hold a pointer to type ________.
int
This ______ is the is the location of another object (typically another variable) in memory.
memory address (pointer)
The & is a unary operator that returns the ___________.
memory address of its operand
Global Static Variables are variables defined __________.
outside the scope of all blocks
___ is the symbol for a hex, decimal address
p
___ is the symbol for an unsigned address.
u