+ 1
How to end input in c?
How to end input with entering zero or any number????
4 Antworten
+ 1
there are mant ways to do this
you can use loop and if number==0 then break use such types of conditions
Use like this
while (scanf("%d",& variable)>0)
{
}
+ 1
It depends! If your program only accepts ASCII numerals to perform an action, then checking the char returned by getchar() may be enough.
If your program is parsing string commands then you could do something like this:
https://code.sololearn.com/ca34a18A146A
For range-based input you have two alternatives:
1. You can ask the user up front how many values should be entered.
2. End the loop if a blank line (or a specific value is entered).
Which one of these are the most effective depends on what kind of input you're dealing with.
+ 1
Just use a while loop and comapre the input with your number and use break statement when you got the right number! That's all
+ 1