Advertisement

Automatically closing

Started by October 13, 2002 07:32 AM
11 comments, last by fivepointo 22 years, 1 month ago
The thing I always use with this problem is this:

At the end of your code, right before your "return 0;" in your main(), put "cin.get(); cin.get();" and see if it works. Have in mind that you need to include "iostream" (iostream.h) and you have to use the namespace std, i.e put "using namespace std;" right below all your includes.

@mikaelbauer

Super Sportmatchen - A retro multiplayer competitive sports game project!

It is very common that a guy who just got their compiler thinks. -Right, let''s make a game. Well, it is simply not that easy. You have to learn how to crawl before you can walk, and walk before you can run. Take a deap breath and step back. Because if you really, can''t solve this one then you are way over your head making a game. Besides, you clearly say that you don''t want to use cmd for you programs. This means that you are after win32 and not console programing. There is a real difference programming in console and win32. This is exactly why I created an API for my students so that they can code using standard c/c++ but still get win32. It is a lot of work behind that so you should think twice before knocking down the language. What you need to think about is what you want to do. Clearly it is win32 so we already get that part. Well, in that case you must for starters have a main function that is called "WinMain" not "main" secondly you don''t use console programming in windows you need windows programming. There is a whole lot you need to do before you see anything on the screen.
I am not talking about simple messageboxes here if someone got clever. Get out to a bookstore and buy a book about windows programming first. Get through that (should take you about a month) then you can start making simple games. But expect that it takes a year before you really get everything and can rank yourself among the most programmers. If you by then want to make a real game expect another year. So, don''t go thinking you can make a game before two years if it is going to be any good.
Advertisement
Open MS-DOS Prompt, drag your compiled program file on to the MS-DOS Prompt window. If you want to pause your program enter this code, although I do not recommend it. I use getch() for pausing console programs:

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
cout << "Hello, world!\n";
system("pause");
return 0;
}

[edited by - Neverwinter on October 13, 2002 11:31:15 AM]

This topic is closed to new replies.

Advertisement