Hi all; I'm trying to figure out how to read the contents of a text file and put them into a struct.
For example, the text file that I have contains this:
91.4, 1.76, Mike Jones
87.5, 1.84, John Marshall
88.0, 1.75, Ryan Musi
.....and so on...
the text file goes on with more names (the numbers in the first two columns represent the weight and height).
My question is how can I put that data into an array of structs so I can later use it for other calculations.
The struct will look something like this:
typedef struct
{
double weight;
double height;
char name[50];
} person;
then I will create an array of structs for each person but right now my 'problem' is getting the weight, height and name and putting them into a struct.
Any help, idea, suggestion will be appreciated. Thanks in advance.