I\'m almost certain this has been asked before, but I can\'t find it being answered anywhere.
When can I omit curly braces in C? I\'ve seen brace-less return>
An example:
int a[2][2] = {{1, 2}, {3, 4}};
you can use the valid equivalent form:
int a[2][2] = {1, 2, 3, 4};
Some verbose compilers may warn, but it is valid.
Note that for the if
statement (same for the while
, the for
statement, ...) the {}
are not omitted. They are just not requested. The if
statement has this syntax:
if (expression) statement
If you want a multiple statement instead of a single statement you can use a compound statement which is surrounded {}
.