Simple C: How do I scan this information in properly?

Posted by Doc on Programmers See other posts from Programmers or by Doc
Published on 2012-03-22T22:08:41Z Indexed on 2012/03/22 23:37 UTC
Read the original article Hit count: 153

Filed under:
|
|

OK this is a simple question but for some reason I just can't get it right. I have to scan from a file hundreds of lines of code and store it in a array (which I can normally do a ok job with) however At one point the code will specify a number that then corresponds to the next batch of chars ints and floats going into various arrays.

As I know I am not describing this correctly here is a example.

one line of the file I am reading will contain something close to this.

0221 T 2 S P 850 150 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Name_of_place

0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom

the problem I am having is This part here

0221 T 2 S P 850 150 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Name_of_place

0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom

The rest after this is Generally the exact same however at this point the number at the front descides all the values that are going in. I am almost completely lost on how to write a way that can scan this and store the data into arrays correctly

© Programmers or respective owner

Related posts about c

    Related posts about beginners