Thread: A couple (hopefully) simple questions.

  1. #1
    Registered User
    Join Date
    Jun 2010

    A couple (hopefully) simple questions.

    I've just started learning C++ and just for fun and practice, I'm making a very, very simple text based game. The player is asked to choose from several actions, each represented by a number which the player inputs to perform the desired action. Anyways, I have two questions which I have not been able to find answers to.

    First, is there a way to make it so that when new text is generated, the console scrolls down so that the new text is at the top of the console, rather than below everything else? I think it would make my program look much cleaner that way.

    Second, after the player chooses an action and presses one of the number keys, they must press "enter" before the program recognizes the input. How can I change that? I would like to do it in such a way that the program automatically registers the keystroke without requiring further input.

    I hope that was clear enough and you can understand what it is I'm trying to accomplish.

    Thank you!

  2. #2
    The Autodidact Dante Wingates's Avatar
    Join Date
    Apr 2010
    Maybe using system("cls") would help you.. Also, if you really must, use conio.h and call the function getch(), it does exactally so, but it wont print the value entered, you must do it yourself, store it into a char variable and print it

    Oh yeah, that is if you're using windows.

    Also if you will be getting numbers using getch, then it would be necessary to convert them to their numeric values, which is fairly easy.. For example, char 1 = 31h, and number 1 = 01h. So, all you gotta do to convert it is to turn off the HO bits(the "3" from 31h), so that it would be 0000 0001, while 31h = 0011 0001. Simply do this:

    someVar = 0x3* & 0xCF or someVar = 0x3* & 0x0F
    Last edited by Dante Wingates; 06-23-2010 at 01:06 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple of questions about XOR linked lists...
    By klawson88 in forum C Programming
    Replies: 5
    Last Post: 04-19-2009, 04:55 PM
  2. a couple of questions about System.String
    By Elkvis in forum C# Programming
    Replies: 5
    Last Post: 02-17-2009, 02:48 PM
  3. A couple of Basic questions
    By ozumsafa in forum C Programming
    Replies: 8
    Last Post: 09-26-2007, 04:06 PM
  4. Couple of Questions
    By toonlover in forum Windows Programming
    Replies: 10
    Last Post: 07-14-2006, 01:04 AM
  5. A couple of OOP questions
    By codec in forum C++ Programming
    Replies: 5
    Last Post: 05-03-2004, 07:18 PM