Weird initialization in C
Posted
by pacopepe
on Stack Overflow
See other posts from Stack Overflow
or by pacopepe
Published on 2010-05-23T18:50:49Z
Indexed on
2010/05/23
19:01 UTC
Read the original article
Hit count: 111
Filed under:
c
Hi there,
I have this piece of code and i don't know how it works
#include <stdio.h>
int main(void)
{
int numero = ({const int i = 10; i+10;});
printf("%d\n", numero); // Prints 20
return 0;
}
Why if i delete the second part (i+10;), the compiler gets an error? Why are the brackets necessary?
Thank you ^^!
© Stack Overflow or respective owner