I am trying to understand the comma Operator in C and I have encountered this compilation error. Can somebody help me?
#include <stdio.h>
int main(void)
{
int a = (1,2);
printf("%d", a);
}
I am using a GCC compiler. I expect the variable "a" value to equal 2 and print it out as output by the printf. But the following warning is generated.
Output:
test.c:5:11: warning: expression result unused [-Wunused-value]
int a = (1,2);
^
1 warning generated.