Use of do ... while
The result that I am trying to get is, when I press the 'q' key, the program breaks out of the loop. Right now, it runs through once and then it does not do anything except respond to the 'q' press. I expect the program to keep posting a distance value while the 'q' has not been pressed. Anybody care to set me straight?
Thanks
Ray
Thanks
Ray
void testping(void)
{
int distance;
print("Press 'q' to quit\n");
// while(getChar() != 'q')
// while(1)
do
{
distance = ping_cm(8);
print("%c%d distance = %d%c cm",
CRSRY,1, distance, CLREOL);
pause(200);
} while(getChar() != 'q');
}

Comments