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
program for compiler design in c

Write a program to calculate the timetable for numbers 1 -> 10 and display them as follows. Your solution should use for do loops      #include stdio.h void main() {    char p

You are going to write a function that computes the total interest charged on a credit card before it is paid off. List all the inputs the function will need.

What about Virtual Destructor? describe it.

Write a program that writes your name on the monitor ten times. Write this program three times, once with each looping method.

1. When developing this project in a Win32 Console Applications that includes the precompiled headers, enter in the Name: box, PRJ2[Your Full Last Name][Your First Initial] with no

Develop a function to calculate sum of n even integers starting from a given even integer

A palindrome is a string that reads the same from the both the ends. Given a string S convert it to a palindrome by doing character replacement. Your takes is to convert S to palin

Define Bit Fields Bit Fields permits the packing of data in a structure. This is particularly useful when memory or data storage is at a premium. Usual examples: Packing

Develop G-code generating software Project Description: I'm presently using Slicer on a polymer jetting 3d printer. The toolpaths were thought out for FDM printers and thus a