WAP in C to find out first occurrence of a given character in a string using strstr() function?

#include <stdio.h>
#include <string.h>
int main ()
{
  char string[55] =“This is a test string for testing”;
  char *p;
  clrscr();
  p = strstr (string,“test”);
  if(p)
  {
    printf(“string found\n” );
    printf (“First occurrence of string \”test\” in \”%s\” is”\
           ” \”%s\””,string, p);
  }
  else printf(“string not found\n” );
   return(0);
}
Output :-
strstr.png
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s