Original Post
Here is a C fonction I have programmed and written here in a simplified manner :
void sub(char *desc, char *text) {
char string[255];
char *temp;
while (!feof(stdin)) {
fgets(string, 255, stdin);
if (!feof(stdin)) {
temp = strstr(string, desc);
if (temp == NULL) {
printf("%s", string);
}
else {
printf("%s%s", text, temp);
}
}
}
}
What I am getting is after a line that goes into the else clause ( meaning strstr(string, desc) wasn't null ) the following line there are some garbage characters which are printed, even if it only prints the string which should'nt be affected by strstr. I took strstr usage's ( returning it to a char * ) directly from an example on the net. What am I doing wrong here ?