CSC209H5 Lecture Notes - Lecture 4: Call Stack, Local Variable, String Literal

60 views3 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Free - free the space that was allocated on the heap. Where? int main() { int i; sizeof(int) stack frame for main sizeof(float) int fun() { float i; int main() { fun(); int fun( char i) Main: stack (main gets a space even with no local var) Fun: stack frame (every time you call fun, you allocate a new space and store the local variable inside) * important to initialize the variables to not assume we jump values. * compiler will know how many local variables there are and to allocate space for it. "a", it stores in fun but there is no memory (it is a constant value; its an instruction) int main() { fun( "a" ); int main() { char i[ 10 ] = [10] + [6] (10 in stack and 6 in constant) or. There is a literal in the constant 6 with a size 6.

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