Strchr in c

strchr is used to find the first occurance in the give string.if the charcter exists in the give strind it returns the address of the charcter or else it returns a NULL

syntax:

pointervariable = strchr(string,’character’);

#include
#include
main()
{
char *i;
char x,y[20];
printf("enetr the string");
gets(y);
printf("enetr a charcter");
x=getchar();
i=strchr(y,x);
if(i==NULL)
printf("string dosent exist");
else
printf("string exists in %d postion",i-y+1);
}