+ 1
How to accept input from user until press ENTER in C??
My target: Write a program that let a user to input as many numbers as he wants, one at a time. Once, the user stops, print out the top 3 largest numbers and the average of all input. Now I use array to keep input to data but it has a problem that we don't know How many inputs that user will enter and if we declare array with large number memory like arr[50]; it will be a problem later.
1 Resposta
+ 1
Either ask user how many numbers will he input or tell him to enter something other than number to terminate input... You can't overwrite ENTER key functionality as far as I know
And btw, user can enter numbers in form of NUMBER SPACE NUMBER SPACE, when cin sees space it automatically separates numbers and stores them separately in array