|
-
Dec 9th, 2002, 03:34 PM
#1
Thread Starter
Frenzied Member
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
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
Dec 9th, 2002, 05:06 PM
#2
Frenzied Member
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
-
Dec 10th, 2002, 10:34 AM
#3
It probably reads an old newline still in the pipeline. You could try adding this before reading:
fseek(stdin, 0, SEEK_END);
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|