Because of the semicolon immediately after the while condition, this loop does nothing!
The code in the curly braces (lines 10 to 12) is executed exactly once; it totally ignores the while in line 9.
Furthermore: i is an array of integers (of length 1), whereas r is a single integer. Obviously, it doesn't make much sense to compare an array to an integer. Actually, in the C programming language, an array is a pointer to the first element. That is why you get the compiler error about comparing a pointer to an integer.
Rachel69 wrote:
scanf("%d,&i[0]");
This use of scanf() function is wrong too. You probably want: scanf("%d", &i[0]);
But why i needs to be an array at all? Why not just do something like this, to read a single integer:
Even in C, there is distinct type for array (it is not the same as a pointer type).
However,
Any lvalue expression of array type, when used in any context other than
. as the operand of the address-of operator
. as the operand of sizeof
. as the string literal used for array initialization
. as the operand of _Alignof (since C11)
undergoes an implicit conversion to the pointer to its first element. https://en.cppreference.com/w/c/language/array#Array_to_pointer_conversion