4 ms·
You mean: #include <stdio.h> main() { printf("goodbye, world\n"); }
by CamperBob 15y ago
You mean:
#include <stdio.h>
main() {
printf("goodbye, world\n");
}
- zmitri 15y agoIt's true, he preferred the brackets formatted this way.
- nikcub 15y agoit is a sure-fire way to distinguish between developers who learnt to code a while ago from K&R and those who didn't. I can't stand looking at braces on new lines. It is all from back when a new line was something to be treasured as displays were bad.
- ajays 15y agoExactly. On a 24-line VT100 display, you bet that every line was important!
- msl 15y agoActually, my copy of the second edition K&R seems to have the opening brackets on new lines when it comes to function declarations, so: main () { but: while (){ and: if(){ I don't have a copy of the first edition at hand but I seem to remember that it uses this same style. //msl
- vsrinivas 15y agoThe first edition has opening brackets for functions on a new line. It also used a space before parenthesis for while loops and conditionals. Return types, when required, were on the same line as a function name.
- buddydvd 15y agoFor functions declarations, K&R style says braces open on new lines. http://en.m.wikipedia.org/wiki/Indent_style http://en.m.wikipedia.org/wiki/Indent_style
- sgerrand 15y agoAs should we all.