I need help separating a file into strings. The data looks like this:
abe lincoln, 35.2, 10.75
george bush, 40, 20.50
b clinton, 50, 20
john adams, 45, 12.00
The instructor wants us to separate each item into its own string and convert the strings for hours worked and hrly wage into doubles. My primary question is how to separate the strings using the function he provided to us.
an aside: your instructor's mixing of C and C++ paradigms for that third argument string temp[] is rather bizarre - it would be much better as vector<string>& results, but maybe you haven't learned STL or references yet - in its present form, I need to look inside the implementation of his/her split() to understand what to pass into the function
split() requires that you pass in an array of strings at least big enough to hold the number of items to be split into - in your case, that number is 3
so, if you define an automatic variable string items[3]; and pass items into the third argument of split() on Line 36, you should be set (I'm assuming the rest of the code works - I haven't compiled or tried it out)