Console text input

This is a discussion on Console text input within the C++ Programming forums, part of the General Programming Boards category; Heres my situation. I am writing a program that is a console text program but is more interface driven, clearing ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    3

    Console text input

    Heres my situation. I am writing a program that is a console text program but is more interface driven, clearing the screen after something happends as opposed to letting it scroll. I have some text fields where the user should only be able to enter thirty characters. After those thirty characters I dont want anymore showing up and drawing all over the interface I constructed. I have spent a few hours on this using all manner of loops and toying with getch, getche, and getchar - all to no avail.

    I also need to do something when the user hits ESC. Ive been checking chars for 27, but all the if statements Ive tried never seem to catch it.

    Im on Windows XP Home using Dev-C++ 4.9.3.0

    Any suggestions would be greatly appreciated. Thanks for your time.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    80

    kbhit()

    i dont know dev c++ has this function but in turbo c u can use kbhit() function.this function checks for current keystrokes

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    70

  4. #4
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    the below code should do the job.. but let me tell you that the function i used in non standard.. and the rest of the char array may contain junk unless it is initilized to NULL..

    Code:
    # include <iostream.h>
    
    
    int main()
    {
    char holder[30];
    int count=0;
    char ch="";
    
    
    while(ch!=27 && count<=30)
    {
    
    ch=getche();
    holder[count]=ch;
    count++;
    }
    
    
    
    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. User input into a text file
    By Starr in forum C++ Programming
    Replies: 8
    Last Post: 01-10-2006, 07:52 PM
  2. Scrolling text in a DOS CONSOLE box
    By Blizzarddog in forum C++ Programming
    Replies: 4
    Last Post: 04-06-2004, 02:27 PM
  3. How to put a Char into the Input buffer of a console?
    By Aidman in forum C++ Programming
    Replies: 10
    Last Post: 03-09-2003, 09:05 AM
  4. Console Text Scrolling Help!!
    By frgmstr in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2002, 01:37 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21