cout does not put characters on my screen

Hi,

I have a little piece of code that should put characters on my screen, but that doesn't happen when I run it. Can someone tell me what is wrong? Thanks.



#include "stdafx.h"
#include <iostream>

using namespace std;

int main() {

cout << "hey" << endl;

return 0;
}
but that doesn't happen when I run it.

Okay, what happens instead?

If I make this code portable by removing whatever "stdafx.h" is, it works for me, see the link:
http://coliru.stacked-crooked.com/a/53b91527fa6000e1

(FWIW, "stdafx.h" is an artifact of Microsoft Visual Studio's default configuration. Ideally, it wouldn't be there, but it should make no difference to you as long as you're using MSVS.)
Last edited on
Thanks for your reply.

The only thing that happens is that when i compile my code, and then run it, a empty Window appears. I would like to put some text on the window that appears.

Thanks
If you run your code on the shell it works perfectly.
http://cpp.sh/5qch

I guess you use Visual Studio so try to add system("pause");
1
2
3
4
5
6
7
8
9
10
11
#include "stdafx.h"
#include <iostream>

using namespace std;

int main() {

cout << "hey" << endl;
system("pause");
return 0;
} 
Hi,

Thanks for your help, but the problem still persists. Any other ideas?

Thanks
Topic archived. No new replies allowed.