I've seen a variety of input requirements from the moment you touch the code to the present, such as:
1. Enter a line of numbers, ending with-1
2. Enter the string to end with a carriage return
3. Enter 10 digits
Wait a minute
Sometimes it is these basic input problems that hinder the steps of understanding the problem.
The rest of the time did not think that today try to enter a string of numbers into an array, ending with 1
"Code Instance"
int array[1000];
int i=0;
while (Array[i-1]!=-1)
{
scanf ("%d", &array[i++]);
}
It is worth noting that I always thought that while the condition is the array "I"! =-1, if this is the case, each time the loop body input a number, I will add one, so again to judge, the array "I" is not equal to-1, even if the last input is 1, so this input is like chewing a bright mai, can not stop at all.
The input string is the same.
"Code Instance"
Char a[1000];
int i=0;
while (a[i-1]!= ' \ n ')
{
scanf ("%c", &a[i++]);
}
The same thing, just changing the input string.
That's all for the time being, ready to update.
End of input array of C