Today I'm reading 《C-Programming》, when I'm copying the code from the book of a fahr-celsius converting function.
I saw codes like
int lower, upper;
lower = 0;
upper = 300;
And I'm wondering If I can do
int lower, upper;
lower, upper = 0, 300
in C, just like in python and golang.
So I did some experiment, I find if I did it, the file is compilable, but the result will be out of my expectation.
Here is my code and output:
# code
#include <stdio.h>
main()
{
int lower, upper;
lower, upper = 0, 300;
printf("lower:%d\n", lower);
printf("upper:%d\n", upper);
}
# output
lower:1
upper:0
I found no matter what number I tried assign to upper(like 1, -5, 20), the output will be the same.
What happened here?