I have this program but a liitle confused about getting the loop to work. i have to write a program that inputs a text and a search string from the keyboard. using a function strstr locate the first occurrence of the search string of the line of text, and assign the location to a variable searchptr of type char* if the search string is found print the remaninder of the line of the text beginning with the search string then use strstr again to locate the next occurrence of the search string in the line of text. if a second occurrence is found print the remainder of the line beiginning with the second occurrence. hint: the second call to strstr should contain searchptr plus 1 as its first argument.
so far i have this, can somebody help me. Thanks
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char line1[80];
char line2[80];
char *searchptr;
int i;
char found[80];
printf( "Enter Sentence\n");
gets(line1);
printf(" Enter String to Search: ");
gets(line2);
searchptr=strstr(line1, line2);
printf ("%s\n",searchptr);
while (searchptr!=NULL)
{
searchptr=strstr(line1, line2)+1;
}
return 0;
}