{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

1402 16 - COMP1002/1402 Chapter16:StringFunctions...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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 th i bl it t NULL If there is a problem it returns 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
Image of page 3

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

View Full Document Right Arrow Icon