Ok, so I have a file that lists information that I want to store in a struct. It is organized like this:
[
Label
Data
Designation
(these three blank lines are purposely there)
]
(
Type-#
Type-#
...
)
There will be an unknow number of these two different types of listings. They are all in one file, with all the [ blah blah] coming before the ( blah blah ).
So, I want to read the file in, each line at a time, putting the results in a struct. My struct will have a place for the label, data, designation and another for the types and numbers. The numbers have to correspond with the types. How can I have my program run through the file and sort out the data?
I assume fgets would be the best, but how do i stop it from going past the \n and putting the next line in the stuct i am trying to populate?
Also, how do I parse out the Type from the # in the second part?
I will be needing an array of structs for each part, I assume, but I really just need to know the best way of taking in the data and storing it in my struct.
Thanks in advance,
Evan