J
Justme
Novice programmer needs help with using fgets to read and ignore the
first two lines of a file. I've gone thru the previous posting
regarding fgets, but none of them seems to help my situation.
I have airdata file that i have to read, but in other teh fscanf to
work properly, i need to ignore the first two lines, because scanf does
not read spaces.
This is what my current code looks like
#include <stdio.h>
#include <sting.h>
#include <stdlib.h>
int main()
{
FILE * AirFile; //the file that contains the data to be read
FILE *textFile; //the out file for both lines
char text1[1000];
char text2[100]
if (AirFille == NULL || textFile)
{
printf("Failed to open file \n")
return -1;
else if ( text1[0] =='\n')
{ fgets(text1, 1000, AirFile);
fprintf(textFile, "allocating:", AirFile);
}
}
fclose(textFile);
fclose(AirFile)'
retrun 0;
}
first two lines of a file. I've gone thru the previous posting
regarding fgets, but none of them seems to help my situation.
I have airdata file that i have to read, but in other teh fscanf to
work properly, i need to ignore the first two lines, because scanf does
not read spaces.
This is what my current code looks like
#include <stdio.h>
#include <sting.h>
#include <stdlib.h>
int main()
{
FILE * AirFile; //the file that contains the data to be read
FILE *textFile; //the out file for both lines
char text1[1000];
char text2[100]
if (AirFille == NULL || textFile)
{
printf("Failed to open file \n")
return -1;
else if ( text1[0] =='\n')
{ fgets(text1, 1000, AirFile);
fprintf(textFile, "allocating:", AirFile);
}
}
fclose(textFile);
fclose(AirFile)'
retrun 0;
}