According to this question "What does an assignment return?" and What is the result of an assignment expression in C?
Sandro Munda and Ahmed Salah write
- Assign the value 2 to i
- Evaluate the i variable and display it
So, based on the statement above, I expect the following code will output
1
1
1
However, it outputs
1
0
1
Code:
#include <stdio.h>
void func(int a){}
int main()
{
int var;
//////////////////////
var=0;
func(var=1);
printf("%d\n",var);
/////////////////////
var=0;
sizeof(var=1);
printf("%d\n",var);
/////////////////////
var=0;
printf("",var=1);
printf("%d\n",var);
return 0;
}
My question is what makes this difference? Why does assignment in "sizeof()" not work as two other counterpart?