CS 162 Lecture 2: CS 162 – Lecture 2 – Pointer, Array, and Struct Review

25 views3 pages

Document Summary

Cs 162 lecture 2 pointer, array, and struct review. Pointers: pointers == memory addresses, variable declaration: int a = 5; Creates a variable on the stack of size int with the value 5: pointer declaration: int*b = &a; Will print the value stored at the address which b points to. Pointers and functions: void func(int a, int b); Prototype indicating that void func is expecting two parameters of type int to be passed by value. Prototype indicating the void func is expecting two parameters, one of type int* (an address of an int) and one of type int. Since a is of type int** (an address) it will have to be dereferenced throughout the function if the value stored at that address is to be used. A may also receive a new address in the function. Changes made to this variable will persist beyond the scope of this function.

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