P8ntballplayah
2013-04-10 15:17:09 UTC
Example:
16 NICK 140.6 68
59 TOM 250.2 77
I have a dynamic array of structures, where a struct has the above variables. If I create a string variable, say string input, then I can do the following to print each set of data:
getline(fileName, input, ' ');
while(fileName) {
cout << input << endl;
getline(fileName, input, ' ');
}
This reads until the next space or newline and prints what it read. What I'm trying to do is instead take what it read and store that as the respective variable in my array. (i.e. set 16 to the age of person 1, NICK to the name of person 1, etc). I run into problems because input is a string, so all non-string values don't work.
I'm sure there are advanced features to do this, but based on what you can see I'm using above, is there a way to do what I'm trying to accomplish?
Thanks for any help