CSC209H1 Lecture Notes - Include Directive, Global Variable, External Variable

66 views2 pages
24 Apr 2013
School
Course
Professor

Document Summary

To access it in another file, need to do something special. Unlike variables on the stack that"s available only while the function it"s declared in is on the stack: static variables. Static used outside a (function) block means that the variable is only visible in the file in which it is declared (file scope) Used to limit the visibility of the variables. Static used in a (function) block means that the variable lives beyond the duration of the (function) block and is initialized only once, ex. Int q is in memory only in the duration of the function f, it will always be initialized with the value -1. Int j only gets initialized once, on the next function call j will retain its previous value static int i; // outside a block void f(void) { int q = -1 static int j; // inside a block.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents