You are here:   HomeC Programming (Pratical)C Program Find the Greatest Between Four Number
by Dinesh Thakur Category: C Programming (Pratical)

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

What's New and Popular

Search Content

Advance Courses

Basic Courses

Advertise with Us