CSC209H5 Chapter Notes - Chapter 3: C Dynamic Memory Allocation, String Literal, Code Segment

27 views3 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) Memory is thought of as a single mass array. The memory is separated into section which stores a particular type of data. Let"s take the following code as an example int sum( int a, int b) { int i; i = a + b; return i; int z; int main() { z = sum( 1 , 3 ); return 0 ; When the code is saved, the code above is stored in the code segment of our memory. Though the array starts at 0, the code segment will be close but not at 0. As the code is executed, the stack space stores the variables runned in the main and function calls. The variables are stored in first in last out order. In the example above, the stack would store the local variables in the following order: Stack: int a int b int i main.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents