PDA

View Full Version : Help for debug C++ program




sitha
Jul 25, 2006, 03:31 AM
Hi Everybody,
I need a help to modify my program. My program as follows,


C++ Code:
if (found) {
// Read Lines below NODES
while(getline(input, buff)) {
// getline(input, buff);
istringstream tmp(buff);
// format the output
string a, b, c, d, e;

tmp >> a >> b >> c >> d >> e;


output <<b << " " << c << " " << d << endl;
cout << b << " " << c << " " << d << endl;
}
}

I read data from files and put into another file. I am reading the datas as string, Now I want to add "1" to each data (ex: if data is 20 the output should be 21). Pls help me how can I do it.

Sitha.



oexel
Jul 25, 2006, 11:18 AM
the easiest way is probably to declare a,b,c,d,e as int, and simply ++ each one. The >> operator will automatically make the string->integer conversion and likewise when you << to output the integers.

JBot
Jul 25, 2006, 11:19 AM
i dont fully understand how this is working, but can you not use temp vars such as tempA, than go
tempA= A+1;
than do whatever you want with that variable.
Or you can just go A =+1;