K&R (UNIX Kernel) Style Review
The K&R style, so named because it was used in Kernighan and Ritchie's book The C Programming Language, is commonly used in C. It is also used for C++ and other curly brace programming languages.
Ranked in these QuestionsQuestion Ranking
Pro No space is wasted with the opening brace
With this style, one of the advantages is that the opening brace does not take a whole line for itself, wasting a lot of space. The closing brace though is indented on the same level as the control statement it belongs to, making it easier to understand which block of code it's closing.
Con May be hard to insert new lines inside statements if there are no braces
The K&R style uses braces only when necessary. So for example:
But this can be annoying if you need to put something inside that
if statement, because you have to go and add braces to make sure that will be grouped correctly with the statement that was before.