Problem in separating values in text file

Hi guys, i am trying to separate the first 2 values in a array which are the currency name and price in which the values were gotten from singapore yahoo.

Using the follwing command

system("w3m -dump \"http://sg.finance.yahoo.com\" > file.txt ");

I then erased the unnecessary data using .erase command. It works perfectly.

I then stored them into an array, string dataStore[100];

Then i tried using a for loop and also incorporating a stringstream to separate the values. However, it only gets me the first value of the array. i wish to get all values of the currency name and exchange rate May i know what is wrong with my code?

Code snippet below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
for(int i=0;i<counter2;i++)
{
string getCurrent=dataStore[i];
				
istringstream toString(getCurrent);
				
string cName,price;

getline(toString,cName,' ');
getline(toString,price,' ');

cout<<price;
				
}
counter2++;
counter2--;

The array contains the following values.
USD/SGD 1.2596 -0.00 -0.18% USD/SGD USDSGD=X EUR/SGD 1.5256 -0.00 -0.18% EUR/SGD EURSGD=X GBP/SGD 1.9542 -0.00 -0.10% GBP/SGD GBPSGD=X SGD/JPY 62.1393 0.06 +0.09% SGD/JPY SGDJPY=X SGD/HKD 6.1586 0.01 +0.17% SGD/HKD SGDHKD=X SGD/MYR 2.5203 0.01 +0.30% SGD/MYR SGDMYR=X SGD/IDR 7,519.9082 -3.47 -0.05% SGD/IDR SGDIDR=X SGD/CNY 5.0705 0.01 +0.17% SGD/CNY SGDCNY=X AUD/SGD 1.2958 0.00 +0.10% AUD/SGD

edit : i just need to get the currency name USD/SGD and the exchange rate 1.2596
Last edited on
Is this what you need?

1
2
3
If (cName.find("USD")) {
    // print your info
}
sorry, i summarized my problem wrongly. I meant to get all my currencys and exchange rates out and write them to a new text file
Last edited on
You need to copy the file, aren't you?
Look out for CopyFile function
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363851%28v=vs.85%29.aspx
Thanks guys for all your help. I solved it using string tokens =)
Topic archived. No new replies allowed.