hi, ive got this piece of code:
Code:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int ping, bestandopen;
FILE *bestand;
char command[20], bestandje[20];
char buffer[256];
/* ping de hosts, sla de resultaten op een de file.
* per Ip word er een file gemaakt.
* */
for (ping = 0; ping <= 10; ping++) // loop van 1 tot ... (argv?)
{
sprintf(command, "ping -n 1 10.10.100.%d > outfile%d.txt", ping, ping);
system(command);
}
/*
* bestandjes worden hier geopend
**/
for (bestandopen = 0; bestandopen <= 10; bestandopen++)
{
sprintf(bestandje, "outfile%d.txt", bestandopen);
fopen("bestandje", "r");
memset(buffer, 0x00, sizeof(buffer));
while (fgets(buffer, sizeof(buffer) - 1, bestand) != NULL)
{
if (strstr(buffer, "Reply"))
{
fprintf(stderr, "blalal ping timeout..\n");
fclose(bestand);
}
}
printf("FILE_OPENED: %s\n", bestandje);
}
return 0;
}
it opens the files, and I know how to read from a single file using fgets, but how can i loop through the all the files and filter out a word (Reply in this case).
thanx