This is very hard. You see, when the user inputs data your program is not running. It is paused by C until the user presses the ENTER key. You cannot control when the user presses this key.
After that your program resumes and you get to figure out what was entered.
All of the functions (like scanf, printf, etc) are provided just to get you started but they are not robust.
The work around is to examine each character as it is entered. Now then the user enters 1 then 2 then 3 you will need to process
these numbers to make an int of 123. But even now you cannot get the user to stop entering data.
As a beginner, just assume the user does the right thing. Later you can purchase code libraries that do all this hard stuff.
|