CS 162 Midterm: CS 162 - Term Test 1 - Spring 2018 - Oregon State University

187 views33 pages

Document Summary

File separation, makefiles: design tips, makefile information and file i/o, classes vs. structs, classes. 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.