Name: Anonymous 2016-07-25 7:26
Is there any particular reason why it is so uncommon to put the opening brace of a function on the same line as the function declaration? As in
The vast majority of C code examples I've seen put the opening brace on its own line in functions, even when they don't do so for if and while statements and so on. Is there any reason for this apparent inconsistency? Personally, I tend to use the above style for everything - functions, loops, structs, etc. And while that kind of brace style is widespread in K&R/1TBS style, it seems to be almost never used for functions.
int main (int argc, char* argv[]) {
/* ... */
return 0;
}
The vast majority of C code examples I've seen put the opening brace on its own line in functions, even when they don't do so for if and while statements and so on. Is there any reason for this apparent inconsistency? Personally, I tend to use the above style for everything - functions, loops, structs, etc. And while that kind of brace style is widespread in K&R/1TBS style, it seems to be almost never used for functions.