CSC209H1 Lecture Notes - Lecture 3: Call Stack, C Dynamic Memory Allocation, Code Segment

104 views5 pages
School
Course
Professor

Document Summary

C memory model: code and stack segments. Introduction: when using a function to assign a variable and return a pointer to an address to the set variable, a warning occurs. Returns ge(cid:374)eri(cid:272) type as it does(cid:374)"t k(cid:374)o(cid:449) ho(cid:449) it (cid:449)ill (cid:271)e used int *i_pt = malloc(sizeof(int)); *arr_matey = malloc(sizeof(int) * 3); int *arr = *arr_matey: nested data structures, need a nested array of pointers with each element that may itself point to an array, use malloc(sizeof(int *) * [# of elements]) for this. Command-line arguments + type and type conversions: converting strings to integers, c strings are special arrays of char elements, we can declare and initialize a string literal variable like ex. char *s = (cid:862)hello(cid:863); Stores an array of strings: each character pointer in the array refers to an array of characters a string, the argument at position 0 is the name of the executable*** (ex.

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