Jump to content
  • Advertisement
Sign in to follow this  
dahmer45

Back to basics

This topic is 4552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites
Quote:
Original post by slowmike
int main() should return an integer.
Technically you don't have to
but it's good practice.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!