I just downloaded Visual Studio 2013. When I compile C, it doesn\'t show me my output. The output screen will show up for a brief second and then disappears.
I first used the metioned getchar() and breakpoints solutions but this is no good if you want the program to end (for example if you are using a memory leak detector). I got over this by redirecting the output to a file. You can do this by inserting >output.txt
in the command line option under the debug section of project properties
To keep your screen from closing you can use getchar() as follow in Visual studio:
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
cout << "Hello\n";
getchar();
}
#include <stdlib.h>
#include <stdio.h>
int main()
{
printf("hello world");
system("pause"); //this pauses the program until you press any key
return 0;
}
the output will be:
hello world
press any key to continue ...
add this code before return 0
;
int num;
scanf ("%d",&num);
or
getchar();
You can also hold CTRL + F5 to get the window to stay open.
There's several things you can do (I'm assuming you're using Windows):
Visual Studio Command Prompt
program.getchar();
before returning to the OS.system("pause");
before returning to the OS.