Starting Off
Ok. I''m really hyped up about getting in to game dev. I''ve read the beginner articles on the site. I just have a few questions. I''m actually just starting C++. I have MS Visual C++ and a few learning books. What else should I have??
Also when I compile the "Hello World" Program it flashes on the screen for a split second in a DOS window then closes.I think this is to do with WindowsXP Would this make a problem for further programming???
For Sale: One Parachute, Used one, Never opened, Small Stain.
For Sale: One Parachute, Used one, Never opened, Small Stain.
start the program from the command line
start -> run -> cmd
the window closes because the program ended
good luck
start -> run -> cmd
the window closes because the program ended
good luck
"may the source be with you"
Its not to do with winxp. You see all the hello world program does is tell the app to display teh string "hello world" on screen. so after the app does that it has nothing else to do so it exits. You can fix this by telling the application to let the user press a key before it exits.
first include conio.h.
#include <conio.h>
the header file conio has the prototype for function "getch()". You can use getch() to get a key code from the user. so at the end of your program do something like
that asks the user to hit a key and then get a key. so the app will stay there until the user presses a key.
[edit] greater then/lesss then tag fix [/edit]
:::: [ Triple Buffer V2.0 ] ::::
[edited by - IFooBar on February 1, 2003 4:54:40 PM]
first include conio.h.
#include <conio.h>
the header file conio has the prototype for function "getch()". You can use getch() to get a key code from the user. so at the end of your program do something like
cout<<"Hit a key to exit"<<endl;getch();
that asks the user to hit a key and then get a key. so the app will stay there until the user presses a key.
[edit] greater then/lesss then tag fix [/edit]
:::: [ Triple Buffer V2.0 ] ::::
[edited by - IFooBar on February 1, 2003 4:54:40 PM]
[size=2]aliak.net
Hi. Welcome to the wonderful world of game development, enjoy your stay...
For getting the basics sorted, you have all you need - MSVC++ is enough to make simple text games. Later on, once you're comfortable with the language and the 'overview' of a game (the architecture), then you'll want to move on to more graphical stuff. You'll need tools for that, but that's still a couple of months away, so worry about it then.
The problem is that when your program has finished, XP automatically closes the DOS box. You can make your DOS box stay up on the screen:
while(!kbhit());
Add that line at the end of your main() function, and the result should be that your program sits there until you press a key. You may need to #include <conio.h> as well.
[Edit: damn you rexizt and IFooBar with your speedy clicker fingers]
Superpig
- saving pigs from untimely fates, and when he's not doing that, runs The Binary Refinery.
[edited by - Superpig on February 1, 2003 4:55:14 PM]
For getting the basics sorted, you have all you need - MSVC++ is enough to make simple text games. Later on, once you're comfortable with the language and the 'overview' of a game (the architecture), then you'll want to move on to more graphical stuff. You'll need tools for that, but that's still a couple of months away, so worry about it then.
The problem is that when your program has finished, XP automatically closes the DOS box. You can make your DOS box stay up on the screen:
while(!kbhit());
Add that line at the end of your main() function, and the result should be that your program sits there until you press a key. You may need to #include <conio.h> as well.
[Edit: damn you rexizt and IFooBar with your speedy clicker fingers]
Superpig
- saving pigs from untimely fates, and when he's not doing that, runs The Binary Refinery.
[edited by - Superpig on February 1, 2003 4:55:14 PM]
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Ok guys thanks a lot
For Sale: One Parachute, Used one, Never opened, Small Stain.
Hi there! I''m also a newbie and had the same prob, but found
system("pause");
which seems to do the job and I''ve been using it ever since. I noticed that you guys didn''t suggest this though. So I need to ask, Is this okay to be using or have I just picked up another bad habit?
system("pause");
which seems to do the job and I''ve been using it ever since. I noticed that you guys didn''t suggest this though. So I need to ask, Is this okay to be using or have I just picked up another bad habit?
how come all console apps i make dont end as desribed above ?
instead it stays open displays - Press any key to continue
pushing a key closes the program.
im using visual c++ 6, even a do nothing program does the same
int main()
{
return 0;
}
instead it stays open displays - Press any key to continue
pushing a key closes the program.
im using visual c++ 6, even a do nothing program does the same
int main()
{
return 0;
}
deal,
Visual C++ 6 does that on alot of machines, like mine for example. But if you run the .exe from the debug folder it will give you the same problem as above.
Visual C++ 6 does that on alot of machines, like mine for example. But if you run the .exe from the debug folder it will give you the same problem as above.
MrManby- I''m gussing all the replys these people have given you are just confussing you even more and don''t know enough c++ to use them correctly. I get the same problem but the easy way to fix it is to push ctrl+f5 which will compile and run the program in MSVC++. The difference is when you push ctrl+f5 it will pause the program as soon as its done running instead of closing it.
-----------------------------
Programming is confussing!
AIM: Trebor DoD
-----------------------------
Programming is confussing!
AIM: Trebor DoD
-----------------------------AIM: Trebor DoDHompage: Thinking Digitally: My Web Blog
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement