PDA

View Full Version : Help me about string and double




sitha
Jul 26, 2006, 02:13 AM
Hi Everybody,

I am writing a program to deal datas from a file.
My code is,

while(getline(input, buff)) {
// getline(input, buff);
if (buff.find("ELEMENTS")!= string::npos) {
found2 = true;
break;
}

istringstream tmp(buff);
// format the output
string a, b, c, d, e;
tmp >> a >> b >> c >> d >> e;
cout<< b << " " << c << " " << d << endl;
output << b << " " << c << " " << d << endl;
}

Here I am reading datas as string, But I want to do erithmetic operation to my datas so I changed string to double.
Now this the problem, Say my input is as follows,

10 20 25 60 75
23 12 23 63 25
12 63 25
When I use as string it works good, but when i put double it copys the datas as follows,

20 25 60 75
12 23 63 25
63 25 63 25
It put the previous line data to the empty space. How can I debug it. Please help me.

Sitha.