/*WAP to search a character in a string*/
#include<stdio.h> #include<conio.h> #include<string.h> main() { char *ptr, str[50]; int ch; // Input of String & character printf("\n Enter the String \n"); gets(str); printf("\n Enter the character to search "); ch = getchar(); // Searching the character ptr = strchr(str,ch); if(ptr == NULL) printf("\n Not Found"); else printf("\n The character %c is at the position %d\n",ch,ptr-str); getch(); return 0; }