Hey again,
So this time I am trying to make a function to call twice instead of repeating the chunk of code twice. When I was not using the function the code worked fine so it seems like I set up the function wrong. Here is what I have when the 'invalid storage class' error occurs:
Code:
static void getAndPrint (char mainFile[], FILE *search);
void getAndPrint (char mainFile[], FILE *search)
{
char data1[256];
char data2[256];
char line[256];
char term[12] = "FindMe";
char dest[] = "/home/user/Desktop/folder/";
strcat (dest, mainFile);
FILE *data;
data = fopen (dest, "w");
if (search != NULL)
{
while (fgets (line, sizeof(line), search)
{
if ( strstr (line, term) != NULL)
{
fgets (data1 -2, sizeof(data1), search);
fprintf (data, "%s\n", data1);
fgets (data2 -2, sizeof(data2), search);
fprintf (data, "%s\n", data2);
}
}
}
fclose(search);
}
Thank you for your time.
Dominic