Page 98, Exercise 5 : strchr1() function
char s1[MAX_SIZE] = {"hello, world!"};
char *chPtr;chPtr = strchr1(s1,ch);
if (chPtr)
printf("%c found at position %s\n", ch, chPtr);
|
char *strchr1 (char *s, char c)
{ /*return a pointer of c in s
This version is case sensitive
Exercise 5 */
int i;
for (i = 0; i < strlen(s); i++)
if (c == s[i]) return &s[i];
return NULL;
}
|