Turn Desktop View Off
by Dinesh Thakur

The strchr function finds the first occurrence of a specified character in a string, If the specified character is found, the function returns a pointer to that character; otherwise, it returns a NULL pointer. Initially, the strchr function is used to locate the position of the first ' l ' character in strings and its address is assigned to pointer result.

#include <stdio.h>
char *strchr(char *string, char letter);
int main()
            int i;
            char strings[2][30]={"hello world","C programming"};
            char letters[]={'l','z'},*result;
            for (i=0;i<2;i++)
                       printf("\n\n\"%s\" was scanned for \'%c\'.\nFunction returned:->  %s",strings[i],letters[i],result);
                       printf("\n\n\'%c\' was not found in \"%s\"",letters[i],strings[i]);
                       return 0;
                       char *strchr(char *string, char letter)
                       char *ptr=NULL;
                       while (*string!=letter && *string!=NULL)
                                return (ptr);

Search For 1st Occurrence of Char in String