Here's a basic question:
How can I take the input from a user and only accept numbers? I know I need to use this start:
do{
ch=getchar();
}while (ch != '\n');
But I know it's not enough. This will block every input, including numbers, so I need to break when input is number. also how do I break not after the first digit of the number?
I tried looking this up with no luck.
thanks!
When you need to perform error checking, do different things based on the input, etc., it's best to read user input line by line and process each line as you see fit.
If you expect to see only one number per line, you can use
sscanfto extract numbers from each line.