You've come to the right place then.
You want to parse the file...
Looking at it, sstream is good as it parses a file by whitespace, so you could use this, and chop out the trailing comma which will be in array[0], yes arrays start at zero.
In that case the easiest way to do this is to:
1) Get the contents of the first array which will be X.XXXX,
2) Find the length of this string and substr the contents from start [0] to the [end -1]. (this should remove the comma)
3) Convert this string to a double - again using stringstreams, then store this in an array or vector.
iamthwee
Posting Genius
6,254 posts since Aug 2005
Reputation Points: 1,567
Solved Threads: 476
Skill Endorsements: 33
I know I haven't tried to read the data in here, but everything I'm doing is wrong and I'm just hitting my head against a wall searching the internet.
If you haven't tried to read the data, you haven't done anything wrong -- yet!
And until you actually attempt to read the data, we can't help you fix what you did wrong.
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 36
filename has been declared using type string. stream objects need null terminated strings to associate with a file, so you need to adjust the filename by calling the c_str() method in order to open the file.
using the return value of eof() can lead to bug. If you don't try getting the first value from the file before calling eof() I'd recommend you use the approach of using the return value of the stream input method to control the loop. So instead of:
while(! openfile.eof())
I'd do something like:
while(openfile >> somevariable)
or
while(openfile.getline(somevariable))
etc.
Lerner
Nearly a Posting Maven
2,406 posts since Jul 2005
Reputation Points: 739
Solved Threads: 405
Skill Endorsements: 8
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 36