Stumbled upon this gem at work and it looked weird to me, there were {} that was not a part of a if-case or function-definition in the code. I want to remove the extra {} but do not know if they actually do any difference.
This is a small test-program i created to clarify my question. What i am talking about is the extra {} surrounding the "2 hello world" -print below:
#include <stdio.h>
int main()
{
printf("1 hello world\n");
{
printf("2 hello world\n");
}
printf("3 hello world\n");
return 0;
}
The result here is: 1 hello world 2 hello world 3 hello world
So it actually works !
So my question i guess is:
What is the deal with using extra {} in C? I did not expect this to pass the compilation but it worked great.