ow can i use fgets to read and ignore the first two lines of a file and output into another file



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;

}

.



Relevant Pages

  • Re: gets() is dead
    ... That certainly means I am unable to use fgets() safely, ... char *readstr ... tmp = realloc; ... strcpy(input, buffer); ...
    (comp.lang.c)
  • Re: Is this string input function safe?
    ... return a pointer to mallocated memory holding one input string, ... See my comment after your call to fgets. ... char* malloc_getstr ... before any characters are read, then the ...
    (comp.lang.c)
  • Re: slurping in binary data
    ... Key point to keep in mind here: I was thinking of sscanf, not fscanf() ... How does fgets know to stop? ... 100000001111100 as the line number and put "13" into the data buffer; ... char pattern; ...
    (comp.lang.c)
  • Re: fgets behaviour with strncmp
    ... given that all the characters returned by fgets are guaranteed ... array of unsigned char. ... unsigned char without a conversion taking place. ...
    (comp.lang.c)
  • Re: fgets() equivalent?
    ... I can use fgets() itself, ... The only issue you need to pay attention too, is RAW vs COOK mode. ... In Unix, the proper way of controling the printer, is to use \r\n because Unix is using binary mode. ... int main(char argc, char *argv) ...
    (microsoft.public.win32.programmer.kernel)