Tuesday, September 21, 2004

scanf

From: http://webcourse.cs.technion.ac.il/234117/Spring2004/ar/faq_Homework.html

>>I'm having a problem using scanf. After I enter the username, the following scanf reads the "enter" I clicked. What should I do?

Instead of writing scanf("%c") you can write scanf(" %c") (with a space before %c), and it should work better. The space before the "%c" will read all white spaces (newline, tab and space) and the first non-white space will be read into the "%c". Using the scanf this way will prevent the scanf from reading the "ente

No comments: