Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
c question
Name: Posickle Date: June 11, 2002 at 18:24:32 Pacific
Comment:
how do i make the c program run a function as soon as a button is pressed.
for example, "Press any key when ready" how do i make that work without pressing an enter key ?
i use inkey$ in Qbasic.. i dont know how i do this in c
Name: Jeff J Date: June 11, 2002 at 19:41:35 Pacific
Reply:
If you're talking about a console app, then you just need to use getch()...
printf("Press any key to continue..."); getch(); //rest of code will run after //a key is pressed
In VC, it's defined as _getch(). Unlike getchar(), it won't make the key's character visible, if it could be.
0
Response Number 2
Name: John W. Borelli Date: June 11, 2002 at 21:27:26 Pacific
Reply:
Jeff is, of course, correct. Also, if you need the keyboard or other events to be visible during the waiting for a keypress (i.e. special function keys or mouse clicks) then use the KeyPressed function which returnes a boolean value as true when the keyboard buffer has data and false when the keyboard buffer is empty. This function does this WITHOUT extracting bytes from the keyboard buffer. This way, you can have the key test routine in a loop that can also still check for special events (for example with a case statement block) that may occur while your are waiting for any other key press to continue.
borelli33
0
Response Number 3
Name: nadeem Date: June 12, 2002 at 03:30:44 Pacific
Summary: Hi, I started teaching myself C++ a few days ago. I'm coming along well and learning a lot! My question is, I'm looking to eventually make 32 bit window programs and dos like programs with graphics, a...
Summary: Hello programmers! I have a small and slight set of questions.I'm making a command prompt program thats suppose to look like its formatting the c drive, but of corse it wont. 1)Is there a code to make...
Summary: i'm learning C++ for the first time. This is my question: i'm trying to make a program that will count the number of letters and words. thank you Tk/ ...