Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sitha

macrumors newbie
Original poster
Jul 13, 2006
4
0
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

macrumors newbie
Sep 6, 2002
6
0
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

macrumors 6502
Jan 9, 2006
271
1
Calgary.Alberta.Canada
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;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.