#include <stdio.h>
FILE* f;
int
main(void)
{
char tbuf[1000];
int i;
int row=0;
int rowadd;
int found;
f=fopen("testfile.txt", "r");
if (!f)
{
printf("Error opening file\n");
return(1);
}
fgets(tbuf, 999, f);
row++;
while (!feof(f))
{
found=0;
rowadd=0;
printf(".");
if (strncmp("Node:", tbuf, 5)==0)
{
fgets(tbuf, 999, f);
rowadd++;
if (strncmp(" Priority:", tbuf, 11)==0)
{
fgets(tbuf, 999, f);
rowadd++;
if (strncmp("Destination", tbuf, 11)==0)
{
fgets(tbuf, 999, f);
rowadd++;
if (strncmp("10.1.1.1", tbuf, 8)==0)
{
printf("\nMatch found on line %d\n", row);
found=1;
}
}
}
}
else
{
fgets(tbuf, 999, f);
row++;
}
row=row+rowadd;
rowadd=0;
}
fclose(f);
return(0);
}