News for hackers. Stuff that matters.
Re:Principles for C programming by ktRolster on Thursday March 16, 2017 @03:30AM (#13883192)
I did find this line of code quite entertaining:

     if((r = write(1, toWrite, len)) != (int) len) { /* 1 is stdout! */
If you're going to go to the effort to add the comment, why not just use stdout instead of 1?
Re:Principles for C programming by makapuf on Thursday March 16, 2017 @04:03AM (#13883329)
indeed, it's just a naive example but wouldn't something like

    int written = write(STDOUT_FILENO, toWrite, len);
    if (written != len) 
        { ...
be simpler ?
Re:Principles for C programming by cperciva on Thursday March 16, 2017 @04:01AM (#13883319)
Because stdout is a FILE *. What he should have used is STDOUT_FILENO.