1402 16 - 3/7/2010 COMP1002/1402...

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

View Full Document Right Arrow Icon
3/7/2010 1 COMP 1002/1402 Introduction to Systems Programming Chapter 16: String Functions Notes Adapted from Dr. J. Morrison, Dr D. Nussbaum Arrays of Strings char *pDays[7]; D [0] "S d " pDays[0] ="Sunday"; pDays[1] ="Monday"; pDays[2] ="Tuesday"; pDays[3] ="Wednesday"; pDays[4] ="Thursday"; pDays[5] ="Friday"; pDays[6] ="Saturday"; 2 COMP1002/1402 - Chapter 16: String Functions
Background image of page 1

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

View Full DocumentRight Arrow Icon
3/7/2010 2 Pointers to Strings 3 COMP1002/1402 - Chapter 16: String Functions Walking thro’ Array char **pWalker **pLast ; pWalker, pLast ; pLast = &pDays[6] For (pWalker = pDays; pWalker <= pLast; pWalker++;) {Body of the Loop} printf("%p -> %s\n", pWalker, *pWalker) 4 COMP1002/1402 - Chapter 16: String Functions
Background image of page 2
3/7/2010 3 Functions : gets and fgets char *gets (char *strPtr); /*stdin */ char *fgets (char *strPtr, int size, FILE *fp);/* from file */ Fetches input string till '\n' If there is a problem it returns NULL Otherwise it returns the pointer gets Changes '\n' to '\0’; Not fgets 5 COMP1002/1402 - Chapter 16: String Functions Functions gets and fgets 6 COMP1002/1402 - Chapter 16: String Functions
Background image of page 3

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

View Full DocumentRight Arrow Icon
3/7/2010 4 Functions puts and fputs int puts (const char *strPtr); /*to stdout */ puts Changes '\0' to newline int fputs (const char *strPtr, FILE *fp); /* outputs to file */ fputs does not change '\0' to newline '\0' is dropped
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/11/2010 for the course COMP 1402 taught by Professor Sprite during the Spring '10 term at Carleton CA.

Page1 / 15

1402 16 - 3/7/2010 COMP1002/1402...

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

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