Back to basics
I've decided to throw everything I've learned out the window and re learn C++. So ealier today I made a simple hello world program. But when I run it, it shows a black window and crashes.Heres my source code.
#include "stdafx.h" // MSVC++ throws a fit if i dont include this
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World\n";
}
Someone please help me.
Hi bud,
Well to begin with i would avoid precompiled headers. When you create the project in Visual Studio, uncheck the precompiled headers box. There is no reason for that to crash otherwise. But what it will do is flash up the console box and then exit immediately.
Dave
Well to begin with i would avoid precompiled headers. When you create the project in Visual Studio, uncheck the precompiled headers box. There is no reason for that to crash otherwise. But what it will do is flash up the console box and then exit immediately.
Dave
Ok, when I make a new project I don't see a precompiled headers box. I only see 'Create directory for solution' box. Also what template should I use?
int main() should return an integer.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World\n";
return 0;
}
If it appears and disappears right away, try using this:
cin.get();
or this:
system("PAUSE");
right before your return statement. Neither is great, but they work.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World\n";
return 0;
}
If it appears and disappears right away, try using this:
cin.get();
or this:
system("PAUSE");
right before your return statement. Neither is great, but they work.
Quote:Original post by slowmike
If it appears and disappears right away, try using this:
cin.get();
or this:
system("PAUSE");
right before your return statement. Neither is great, but they work.
Quote:Original post by slowmikeTechnically you don't have to
int main() should return an integer.
but it's good practice.
Yeah, that used to happen to me alot when I had started re learning C++. I am not using SDL for C++. It is pretty cool. Just remember to put in that system("PAUSE"); next time
if(dahmer45 does not enter wat I told him to) {
cout<<"ENTER SYSTEM("PAUSE");\n"; I just had to do that.
if(dahmer45 does not enter wat I told him to) {
cout<<"ENTER SYSTEM("PAUSE");\n"; I just had to do that.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement