Console flashes when ran.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • a27skace
    New Member
    • Jan 2012
    • 1

    Console flashes when ran.

    Hey,
    I am an extreme newbie and when I run my code after compiling it, the cmd just flashes and closes. Now, I know that it is flashing because I haven't paused it but using script like getch() that is prior to return; will not work for me as this will stop the script all too soon. So far this is my code:


    #include <iostream>
    using namespace std;
    int change(int,int, int);


    int main() {
    int x =34, y=45, z=67, sum = 0;
    sum = change(x,y,z);
    cout << sum << endl;
    return 0;
    }

    int change(int x, int y, int z){
    int sum;
    cout << x << " " << y << " " << z << endl;
    sum = (x+y+z);

    return sum;
    }


    At the moment I am using Dev C++ 4.9.9.2 .
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    insert system("pause"; before return 0;

    Comment

    Working...