C program to search for a given character in a string, C/C++ Programming

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;

}

 

 

Posted Date: 10/19/2012 5:45:24 AM | Location : United States







Related Discussions:- C program to search for a given character in a string, Assignment Help, Ask Question on C program to search for a given character in a string, Get Answer, Expert's Help, C program to search for a given character in a string Discussions

Write discussion on C program to search for a given character in a string
Your posts are moderated
Related Questions
how to fill the blank spaces in the board of 4*4 matrix with the minimum of 4 colors and the condition is the adjacent element should not have the same colour


Ask question #Minimum 100 what is friend function is used in c++


For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

F r i e n dly Function: A class can have public members and private members.   The public member can be used through the class using dot operator.   Where as private me

I have a very confusing assignment and I''m struggling to find the right place to begin or how to break the problem down.

5 questions. plus i will provide the "vector.h" for the questions that needs it

What are control structures? - Control structures decide which instructions in program must be executed. - This implies that program flow may not necessarily move from one s

overload assignment opertor to assign the data of one object to anthor