any good tutorials on console commands?
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?
Well... as you''re using c++, here is a reeeeeeeaaaaalllllyyyy simple program that combines those two things:
if you''re looking for tutorials, there''s nothing a search with google can''t solve:
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=c%2B%2B+tutorial
Bye
#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; getch(); cout << "Finish...Bye...";}
if you''re looking for tutorials, there''s nothing a search with google can''t solve:
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=c%2B%2B+tutorial
Bye
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 ]
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 ]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement