Write a C Program demonstrating xstrstr() function

/**************************************************************/
/*Programmed by : Vivek Patel**********************************/
/*For Bugs Free feel to contact********************************/
/*Website : www.vivekpatel.cjb.net*****************************/
/*Email : vivek_patel9@rediffmail.com**************************/
/**************************************************************/

#include
#include

void main(){
char * xstrstr(char *,char *);
char *string;
char *ptr,c[15];
clrscr();
printf("Enter a string : ");
gets(string);
printf("Enter search string : ");
gets(c);
ptr = xstrstr(string, c);
printf("\nOutput of function is : %s\n",ptr);
getch();
}

char * xstrstr(char *str,char *ch){
int i,j,len,k;
char *temp;
for(len=0;ch[len];len++); // for lenngth
for(i=0;str[i];i++){
for(j=0;j temp[j]=str[i+j];
temp[j]='\0';
if(strcmp(temp,ch)==0){
for(k=j;str[i+k];k++)
temp[k]=str[i+k];
temp[k]='\0';
return(temp);
}
}
return(0);
}



Powered by Wufoo