Read each line using fgets(), as in
char buff[BUFSIZ];
while ( fgets( buff, sizeof buff, fdin1 ) != NULL ) {
if ( sscanf( buff, "%s %s %s %s %s",data1, data2, data3, data4, data5) == 5 ) {
// could be a line like
// 00:00:00 R- 0.0654 345 +19
} else {
// might be a line like
// 00:02:00 2.3456 315 +19
}
}
The key point is to read a whole line using fgets(). What you do afterwards is up to you in terms of validation and conversion.
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Offline 7,164 posts
since Dec 2005