Help for debug C++ program

Discussion in 'Mac Programming' started by sitha, Jul 25, 2006.

  1. macrumors newbie

    Joined:
    Jul 13, 2006
    #1
    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.
     
  2. macrumors newbie

    Joined:
    Sep 6, 2002
    #2
    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.
     
  3. macrumors 6502

    Joined:
    Jan 9, 2006
    Location:
    Calgary.Alberta.Canada
    #3
    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;
     

Share This Page