You are here:

C++/C Graphics

Advertisement


Question
Hello Sir,
I m from India.
Sir, I have gone through lines of program from internet and
I've got doubt in following lines :

while(1)
   {
   if(kbhit())
   {
   a=getch();
   break;
   }
   }
Sir please tell me what is role of kbhit in graphics,
because I've came across it in many programs and some were
written in books by great authors but they didn't explained
its meaning. Is it only a variable kind of thing or it has
some specific function in grahics.

Thank You

Answer
Dear Paritosh Singh:

I did a google.com search on kbhit c++ and this is what I came up with:

http://www.cprogramming.com/fod/kbhit.html

kbhit()
Prototype: int kbhit(void);
Header File: conio.h
Explanation: This function is not defined as part of the ANSI C/C++ standard. It is generally used by Borland's family of compilers. It returns a non-zero integer if a key is in the keyboard buffer. It will not wait for a key to be pressed.


So in the example above, it looks like it is waiting until a key is pressed then gets the character of the key that is pressed and breaks out of the loop.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Titus B. Ledbetter, Jr.

Expertise

C , MFC, Object Oriented, Artificial Intelligence

Experience

I have over ten years experience in the field of Computer Science, five years experience developing C/C++. I recently wrote a chess program using Object Oriented, C++, MFC.

Education/Credentials
Master's Degree Computer Science from Johns Hopkins

©2016 About.com. All rights reserved.