1
I am learning C, and as the language in which I was "literate" is Python, I usually make associations to better assimilate.
In Python, I can receive a direct value in the while condition. Ex.:
while int(input()) != 0:
faça isso
It is also possible (in Python and C) to declare a varive before while, receive a new value at the end of each loop and then parse. Ex (in Python).:
n = 1
while n != 0:
faça isso
n = int(input)
But I was wondering if you have any way of doing like in the first example, but in C.
I tried it as follows (in C):
int n;
while(scanf("%d", &n) != 0){
faça isso
}
But it runs the loop even if I type 0.
Thanks in advance.
Have you tried
while(scanf("%d", &n) && n != 0)
?– NoobSaibot