Oh, I see. Fixed.
Now, what I don't understand:
Originally Posted by
Salem
And don't forget about the \n issue.
Where do you see the \n? I only have it on my initial printf that doesn't affect the function. Maybe you mean some other implicit \n that escapes my eye? Thanks in advance.
Code:
void seleccionarArchivo()
{
FILE* fp, * fp2;
char ch[500], x[500], str[500], line[BUFSIZ];
int linenumber = 1;
char term[20] = "Media";
printf("\n Escribe la ruta del documento deseado\n\n");
scanf("%s", x);
fp = fopen(x, "r");
fp2 = fopen("out.txt", "r");
freopen("out.txt", "a", stdout);
if (fp == NULL)
{
printf("El archivo no se ha podido encontrar.");
exit(0);
}
while (fgets(ch, sizeof(ch), fp))
{
printf("%s", ch);
}
rewind(fp);
while (fgets(ch, sizeof(ch), fp) != NULL) {
strcpy(str, "ping ");
strcat(str, ch);
system(str);
if (fp2 != NULL);
{
fgets(ch, sizeof(ch), fp2);
while (fgets(ch, sizeof(ch), fp2))
if (strstr(ch, term) != NULL)
{
printf("IP responde", linenumber);
}
++linenumber;
}
}
fclose(fp);
}