getch|()

This is a discussion on getch|() within the C++ Programming forums, part of the General Programming Boards category; im trying to accept input from the user and meanwhile i want to loop something, for example when i use ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    30

    getch|()

    im trying to accept input from the user and meanwhile i want to loop something, for example when i use getch() to get input, i dont want the program to stop and wait until the user types sometyhing, i want it to display stuff on the screen insteneasouly during the proces of getch(). is this possible? if not is there any other way to accomploish this task?

  2. #2
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    Re: getch|()

    Originally posted by Chobo_C++
    im trying to accept input from the user and meanwhile i want to loop something, for example when i use getch() to get input, i dont want the program to stop and wait until the user types sometyhing, i want it to display stuff on the screen insteneasouly during the proces of getch(). is this possible? if not is there any other way to accomploish this task?

    My guess is this is OS and compiler specific.. I would use kbhit function for this..

    something like

    (Warning:- Compiler/OS specific.. wont run everywere)
    Code:
    while(TRUE)
    {
    
    keep doing something...
    
    if(kbhit())
    ch=getch();
    
    }

  3. #3
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    It really does depend on the OS you're using... if it's Windows, there are a lot of ways to do it.

    It's a matter of how you structure the program.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,659
    Learn all about console programming on Windows here

    gg

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    30
    hmm is win32 api what beginners should learn after learning the basic of c++? like after learning the tutorial on this website?

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,659
    If it all went over your head, probably not.

    The console functions are a tiny subset of the Win32 API. They should be easy to learn by anyone who has a descent grasp of C.

    gg

  7. #7
    Set Apart -- jrahhali's Avatar
    Join Date
    Nov 2002
    Posts
    256
    try using the function getche() (notice the e at the end ). this is different from getch() because it 'echoes' the character typed onto the screen. just remember 'e' for echo hehe

  8. #8
    Set Apart -- jrahhali's Avatar
    Join Date
    Nov 2002
    Posts
    256
    lol..oops misread the question. i guess i'm to eager to help (with things i think i know)..

Popular pages Recent additions subscribe to a feed

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