This preview shows pages 1–7. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: the ith object in a memory block: *(p+i) or p[i] 8: The Sum of a Pointer and an Integer: ith object #define SIZE 3 double *p; if((p = malloc(SIZE*sizeof(double))) == NULL) exit(EXIT_FAILURE); for(i = 0; i < SIZE; i++) 8: The Sum of a Pointer and an Integer: ith object &p[i] &*(p+i) p+i are equivalent. /* read in using */ for(i = 0; i < SIZE; i++) if(scanf("%lf", &p[i]) == 0) exit(EXIT_FAILURE); 8: The Sum of a Pointer and an Integer: Traversals Pointers are often used for traversals in loops, for example double *pi; for(i = 0, pi = p; i < SIZE; i++, pi++) product *= *pi;...
View
Full
Document
This note was uploaded on 02/18/2012 for the course CS 240 taught by Professor Rego during the Fall '08 term at Purdue UniversityWest Lafayette.
 Fall '08
 REGO

Click to edit the document details