Google Ads

Wednesday, May 27, 2009

Substring

SUBSTRING OF A STRING

#include”stdio.h”
#include “conio.h”
#include
void main()
{
char str[10],sstr[10];
int i,j,len,slen,n,f=0,k=0;
clrscr();
printf("Enter the String : ");
gets(str);
printf("\nEnter the Substring : ");
gets(sstr);
len=strlen(str);
slen=strlen(sstr);
for(i=0;i0)
printf("\nSubstring occured %d times\n",k);
else
printf("\nString not found ");
getch();
}

Output will be


Enter the String : Hello world

Enter the Substring : l

The Given Substring : l

Substring occured 3 times

No comments:

Post a Comment