#include #include /* Scans a string for the first occurence of a given character Declaration: char *strchr(const char *s, int c); strchr scans a string in the forward direction, looking for a specific character. This function finds the first occurrence of the character c in the string s. The null-terminator is considered to be part of the string; for example, strchr(strs, 0) returns a pointer to the terminating null character of the string strs. Return Value: þ On success, returns a pointer to the first occurrence of the character c in string s. þ On error (if c does not occur in s), returns null. */ char *strchr2(const char *s, int c) { int i=0; for(; *s && (*s!=c); ++i, ++s); return((*s==c)?s:NULL); } int main(void) { char string[50]; char *ptr, c = 'e'; strcpy(string, "Ermmm.. e"); ptr = strchr(string, c); if (ptr) printf("The character %c is at position: %d\n", c, ptr-string); else printf("The character was not found\n"); return 0; }