CSC209H1 Lecture Notes - C Dynamic Memory Allocation, .Bss, Compile Time

60 views2 pages
24 Apr 2013
School
Course
Professor

Document Summary

User: test b: 5. 250000: size of struct user is 16: Double pointers: most frequently used is for array of strings. Declare an int, compiler reserves 4 bytes. Declare an array of 4 ints, compiler reserves 16 bytes. 4 bytes int x = 2; int a[4]; int *b; int main() { Symbol table: main 0x804837c . text f9 x 0x8049588 . data 04. 0x8049688 . bss 04 a 0x804968c . bss 10: variables declared outside any functions are global variables. Things can happen to these variables and can"t easily follow the path of where the variables change sources of error. Better to put inside main functions: program nm prints out all the symbols of an executable. Shows which memory segments these symbols are found in. Even main has an address in the code component of the memory region. Dynamic memory allocation in c: memory is reserved in an unused slot in the heap via malloc void *malloc(size_t size);

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