What I have is a loop that should read the result on one hardware every 500 milliseconds. This part is working fine. However, when I try to enter cin.get to select the "n" key to stop the loop, I get only as many outputs as the number of keystrokes to this point. If I press any keys (except "n") several times and then type, I get a few more outputs. I need the loop to continue the loop without any interaction until I want it to stop.
Here is the code:
for(;;)
{
count1++;
Sleep(500);
analogInput = ReadAnalogChannel(1) / 51.0;
cout << count1*0.5 << " " << analogInput << endl;
outputFile << count1*0.5 << ", " << analogInput << endl;
if (cin.get() == 'n')
break;
};
My output is as follows (there are two keystrokes to go to this stage in the program), if I do not press a few more keys, then type:
0.5 0 // as expected
1 2 // as expected
should be more values until stopped
, , .
!