Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


any good tutorials on console commands?

This topic is 5732 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

Hi, I''m working on programming my first c++ console game, and there are alot of things I''d like to be able to do, but I''m not sure how. For example: -I want to be able to prompt the user for a single char, and then once they press a key, read the char and continue, as opposed to waiting for them to press enter. -On a very related note, I want to have a "press any key to continue" command. Anyone know how to do this, or a good tutorial?

Share this post

Link to post
Share on other sites
Well... as you''re using c++, here is a reeeeeeeaaaaalllllyyyy simple program that combines those two things:

#include <iostream.h>
#include <conio.h>

void main()
char c1;

cout << "Char -> ";
cin >> c1;

cout << "Char was " << c1 << endl;
cout << "Press any key to continue..." << endl;

cout << "Finish...Bye...";

if you''re looking for tutorials, there''s nothing a search with google can''t solve:



Share this post

Link to post
Share on other sites
a) It depends on your platform - C++ has no notion of keyboard or console, only streams, and the standard behaviour of the run-time library is to wait for a carriage return before providing the data to the streams.

b) On MS platforms, look at the conio.h header. On Unix platform, look at the ncurses.h header.

c) Don''t ever use <iostream.h> - despite the fact that many C++ books use it, it is not a C++ header. Use <iostream>

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post

Link to post
Share on other sites
Hey thanks for the help, one problem though.

When I use the getch() command, it makes the screen go blank. When a key is pressed, everything re-appears.

Share this post

Link to post
Share on other sites

  • 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!