Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

farmerdoug

macrumors 6502a
Original poster
Lines in my files are not of the same length. However the date is always first.
For a while

fscanf(file, "%s %s \n", date, therest);

worked in that everything past the date was dumped into therest. I don't know what I did but it doesn't work anymore.

How do I read the first element of every line, independent of what follows?
 
fgets() to read the line into a buffer.
Check for EOF, errors, incomplete lines, etc.
sscanf() to parse the data from the line buffer.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.