Reputation: 73
Is there a way to read a HH:MM format from a file using fscanf()
, and treat it like an int? The file has this format :
3 14:50 20.10
Is it possible to do something like fscanf(fp, "%d ... %f, &a, &b, &c);
and b
will have 1450?
Upvotes: 1
Views: 91
Reputation: 16157
I'm afraid you can't do this in a line. However, you can:
fscanf(fp, "%d %d:%d %f", &a, &b1, &b2, &c);
b = b1 * 100 + ((b1 > 0) * 2 - 1) * b2; // in case b1, b2 are the different sign.
Upvotes: 4