News for hackers. Stuff that matters.
Re:Deconstructing "K&R C" by NickPollard on Wednesday January 11, 2012 @06:41AM (#3451341)
I'm currently experimenting with a hybrid of this and K&R style, that would look like this:

  while ((len = getline(line, MAXLINE)) > 0)
      if (len > max) {
          max = len;
          copy(longest, line);
          }
    
      if (max > 0) /* there was a line */
          printf("%s", longest);
So far I'm finding that it gives good readability, doesn't waste too many lines on braces, and doesn't run into many issues of accidentally leaving braces out.

I started it after having started writing lisp and python, and I'm getting used to just ignoring the braces and going by indentation, which this style emphasises.

There are no comments on this comment yet.