program is to search for a given character in a


Program is to search for a given character in a string:

Program is to search for a given character in a string and print point of match

char *stsearch(char *string, char search);

void main()

 {

 clrscr();

 char string[20],search,*temp;

 int i=0;

 cout<<" enter a string ";

 gets(string);

 cout<<" enter the letter to be searched in a string ";

 cin>>search;

 

 temp=stsearch(string,search);

 

 cout<<"String after char search : "<

}

 

char *stsearch(char *string, char search)

{

 int i=0;

 while (string[i]!='\0')

   {

     if(search==string[i])

     {

                cout<<" The Character is found : "<<"\n";

                return &string[i];

     }

     i++;

   }

   cout<<" The char is not found ";

   return NULL;

}

 

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: program is to search for a given character in a
Reference No:- TGS0174918

Expected delivery within 24 Hours