L08 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CME/Energy 211 Margot Gerritsen Shela Aboud Emmet Caulfield
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lecture Overview • Pointer Arithmetic • void and NULL • Dynamic memory allocation
Background image of page 2
Libraries and Files • Leave the function in the same file as the main() function – Limit the size of a source code file to 10k-15k bytes. • Put the function in a separate file – Group all functions that are conceptually related together. – Group all general-purpose functions together. – Group all top-level functions together or in main(). Top-level functions defines the operation. • Place it into a library – Putting something in a library instead of a file is essentially the same,
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Class tips for successes • Don’t believe everything you read! • Screencasts – these are very important!! • Read discussion board/Google
Background image of page 4
Pointer Arithmetic 6 7 8 9 10 x[0] x[1] x[2] x[3] x[4] int x[5]={0}; Int *p1,*p2; int j,k; for(j=0,k=10;j<5;j++,k++) x[j]=k; p1=&x[1]; printf(“%d\n”,*p1); p2=p1+2; printf(“%d\n”,*p2); x p1 p2 Since arrays are stored in a sequential block of memory so adding or subtracting from the address is equivalent to pointing to another element in the array.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Pointer Arithmetic 6 15 8 16 10 x[0] x[1] x[2] x[3] x[4] int x[5]={0};
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/17/2010 for the course CME 211 taught by Professor Staff during the Winter '10 term at Stanford.

Page1 / 21

L08 - CME/Energy 211 Margot Gerritsen Shela Aboud Emmet...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online