#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20],b;
char *ptr;
clrscr();
printf("\n Please Give The STRING OF A : ");
scanf("%s",a);
flushall();
printf("\n Please Give The CHARACTER TO B : ");
scanf("%c",&b);
ptr = strchr(a, b);
if (ptr)
printf("The character %c is at position: %d\n", b, ptr-a+1);
else
printf("The character was not found\n");
getch();
}
--------------------------------- OUTPUT ---------------------------------
Please Give The STRING OF A : NAYAN
Please Give The CHARACTER TO B : Y
The character Y is at position: 3
--------------------------------------------------------------------------