0

Given file with the only line:

001005023000.0028

How can I scan this file (file.txt) and create structure like this:

a=001  b=005  c=02  d=3000.00  e=28  

I want to do it with fscanf, but my problem it's that in this line don't exist spaces, and thus, I don't know what is the format that I need to write in fscanf(..)

I've seen this and still I don't understand how to do it.

zero323
  • 322,348
  • 103
  • 959
  • 935

1 Answers1

1

Did I understand correctly, you are reading in a fixed-field line?

You could try

unsigned int a, b, c, e;
float d;    
fscanf(file, "%3u%3u%2u%7f%2u", &a, &b, &c, &d, &e);
printf("a=%u b=%u c=%u d=%f e=%u", a, b, c, d, e);
niksu
  • 61
  • 4