daviddoria
Posting Virtuoso
1,996 posts since Feb 2008
Reputation Points: 437
Solved Threads: 204
1) Easiest way, copy ALL of the data into notepad
2) On the notepad, click Edit->replace. Now replace all ',' with ' '
3) Now you can read in the date as a string, and the price as a double
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
Thanks for the suggestion to change the file in notepad. I understand how that would work. Unfortunately, I am working on this as part of an assignment for a class and have to deal with the file as is.
Try something like this then :
string data = "01/01/2010,37.58";
string::size_type pos = data.find_first_of(',');
string date = data.substr(0,pos); //contains "01/01/2010"
string strPrice = data.substr(pos + 1); // contains "37.58"
float price = atof( strPrice.c_str() ); //contains 37.58
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608