Table of Contents
show
Use of strchr( ) function
#include <stdio.h>
#include<string.h>
int main()
{
char s1[100],ch='a';
char *ptr;
puts("Enter string1");
gets(s1);
ptr = strchr(s1,ch);
if(ptr == NULL)
{
puts("character not present");
}
else
{
printf("string present at %d",ptr-s1);
}
return 0;
}
Output
Enter string1
Hello all
string present at 6
Views: 0