/* string library functions */ /* 'strchr' searches for a character in a string */ /* printf doesn't like being handed a NULL string, let's fix that... */ #include #include int main() { char string1[] = "Computers are electronic machines"; char *foo; /* a pointer to a character, which will point to a string in this case. */ printf("Our string is: %s\n", string1); foo = strchr(string1, 'c'); if (foo != NULL) { printf("Searching for 'c' in the string resulted in...\n"); printf("%s\n", foo); } foo = strchr(string1, 'k'); if (foo != NULL) { printf("Now we'll search for 'k'...\n"); printf("%s\n", foo); } }