The "strchr" is used for scaning the string for the first occurence of a given character.
char *strchr(const char *s,char c);
The "strchr" function accepts 2 arguments
The function returns NULL if the characer is not found in the string.
#include<iostream> using namespace std; #include<string.h> int main() { char str[10]; char *ptr,k='c'; cout<<"enter string "; cin>>str; ptr=strchr(str,k); if(ptr) cout<<"the character "<<k<<" is at position "<<ptr-str; else cout<<"the character was not found "; return 0; }