CISC 220 Lecture Notes - Lecture 8: Type System, Complex Instruction Set Computing, Call Stack

69 views7 pages

Document Summary

Arrays: remember: int nums[20, cant make it bigger/smaller, no new", just the above instantiation, array elements are not initialized, no way of finding length, must keep track, c does not check array indexes. So if you go out of scope, it will give you garbage, not an error message: this means you can retrieve/write from/to addresses outside of the allocated memory of the array. Ex: int i = 5; int * p; p = &i printf( %d\n, *p); /* prints 5 */ *p = 17 /* this changes the value of i to 17 */ You can also do: float * ptr1 = &num1; Ex2: float num1 = 5. 3; float * ptr1 = &num1; float * ptr2 = ptr1; /* ptr2 is the same as prt1 */ printf( %0. 1f, %0. 1f\n , *ptr1, *ptr2); Output: 5. 3, 5. 3 float num2 = 7. 6; ptr2 = &num2; printf( %0. 1f, %0. 1f\n , *ptr1, *ptr2); Output: 5. 3, 7. 6 float * ptr3 = ptr1;

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