CS136 Lecture Notes - Lecture 10: Call Stack, Memory Address, Local Variable

40 views3 pages

Document Summary

Pointer can help the function to return more than one value. Pointer (*) points at the memory address of a type. Passing structures: with partial initialization, all the fields didn"t get mentioned is set to 0. Argument is the structure: void my_func (struct bigstruct b1), void main { struct bigstruct bs = {0, 1, 2, 3}; my function (bs); Pass a pointer to the structure instead of the structure itself (8 bytes: void my_func (struct bigstruct *b, allows the function to mutate the fields of the structure. Dot operator has higher precedence: (*p1). x. The arrow operator (->: ptr -> field, points at a field, can only be used with a pointer to a structure. Const int *p = &j: cant change j through the pointer (what p points at is constant, can change j by j+, can change p (p is mutable variable): p = &i; Minimizing mutative side- effects: avoid mutable global variables.

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