-
Input from Keyboard
When I use this code:
Code:
printf("Do you want to enter another student? [y/n]");
scanf("%c",&v);
if(v=='y'){
goto EnterStudent;
}
It doesn't allow me to input data from the keyboard but instead it move right to the prompt... All of the files I have opened are closed, so I don't know where it is pulling the data from....
Is there any way to ensure that the data is inputted from the keyboard?
thnx,
squirrelly1
-
Look into gets() and getc() for direct keyborad input - gets() waits for a return key press before returning data to the program, getc() returns each keystroke.
C++ has iostream which gives you .getline
-
It probably reads an old newline still in the pipeline. You could try adding this before reading:
fseek(stdin, 0, SEEK_END);