Continue Functions
Note: All the programs mentioned in this lecture are in:/home/cs352/SUMMER02/lecture7progs/
- CONTINUE FUNCTIONS - Storage Classes: Every variable and function has a type and storage class: Four storage classes: - auto: Declarations inside a block are by default auto, So, keyword seldomly used. When entering the block memory for these local variables is allocated, when exiting memory is freed, and variables no longer have value. see callbyvalue.c - extern: - Declarations outside any function is external. Functions by default are external. - Global to all the functions defined after it. - If an external variable is referred before it's defined or if it's defined in another file then use the extern keyword.(Storage allocation in this case???) See external.c, funextern.c. See also external1.c, external2.c - register: Variables are to be stored in registers (for fast access.) - static: 1-Allows a local variable retain its value from previous invocation. see static.c 2-Can use as external static for privacy see staticextern.c for static external variables. (see external2.c for functions, change localadd to be static and compile external1.c and external2.c together. What happens????) - Initialization: Externals and statics are initialized to 0, no guarantee for automtic variables. see intialize.c - Recursive Functions: A function that calls itself(directly or indirectly) Might make the implementation simpler. However time and space efficiency??? see recfibo.c and iterfibo.c for a comparison. - See calculator.c in /home/cs352/SUMMER02/lecture6progs/calculator/ for a complete example. Also, see calc*.c in the same directory. (Same program in the textbook)