Help Please

Hi, I'm quite new to c++ and i have been having a specific problem. i use devc++ 4.9.9.2 coppiler and everytime i have thre line return o; at the end of my main function, the source code compiles but when i run it, it just closes up instantly. if i change the return o; statement to cin >> a;
where a is a variable i use in my program, the program compiles and runs successfully. i have copied programs directly from textbooks and i get the same error. pls can any one tell me what im doing wrong. Thank you

Comments

  • The console window is *probably* closing upon program termination. You might try something like below. You can also try opening a "cmd" window and then run your program by providing the full path to your application.

    [code]
    int main() {
    // bits of code

    while(cin.get() != '
    '){}
    return 0;
    }[/code]

    HTH


  • Thanks, the piece of code you gave solved the problem.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories