Search code examples
creturn

Seeing the output of my program


I am having a problem with a program of mine, as I cannot see the output display. Using a Dev C++ compiler to compile my C program, I debug it to see the output. However my program immediately terminates, so I can't see the output properly.

I ended my program with return 0, and Aldo tried getch(), but even with both endings my program terminates quick.

I want to know if my program endings are wrong, and if so what is the correct way to end a program?


Solution

  • you need the window stop to view the output, is it right?

    if yes, include this library

    #include <stdlib.h>
    

    then add this line at the end of code:

    system("PAUSE");
    

    e.g

    #include <stdlib.h>
    #include <stdio.h>
    
    int main()
    {
    /* do/print some thing*/
    system("PAUSE");
    
    }