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

Assignment Help:

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;

}

 

 


Related Discussions:- C program to search for a given character in a string

Tower of hanoi, application problem of tower of hanoi

application problem of tower of hanoi

Define the increment and decrement operators in c language, Define the Incr...

Define the Increment and Decrement Operators in c language? C offers two special operators -and ++ called decrement and increment operators respectively and these are unary ope

Padovan String, A Padovan string P(n) for a natural number n is defined as:...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of t

Explain the changing field width, Changing Field width The printf() and...

Changing Field width The printf() and scanf() functions from the standard library, use width specifier for controlling the width of its output . Similarly, the ostream class al

Program to spider''s path display to the screen, Spider webs have two types...

Spider webs have two types of silk, sticky silk and strength silk, spiders do not move on the sticky silken threads only on the strength threads. Assume one type of spider creates

Explain integer literal, Integer literal Integer is numbers without fra...

Integer literal Integer is numbers without fractional parts. e.g. 20       // Decimal 024      // Octal     0x14     // Hexadecimal To indicate long, unsigned,

Default value functions, Default Value Functions,  When declaring a functio...

Default Value Functions,  When declaring a function we can specify a default value for each parameter. This value will be used if that parameter is left blank when calling to the f

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd