Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pointers

Name: Anonymous 2010-09-16 5:42

I'm finally reading my K&R, and one thing strikes me: some of these examples are pretty darn obtuse. Please tell me shit like this is frowned upon in the real world:

// Paraphrasing from the ``find'' program in 5.10
#include <stdio.h>

int main(int argc, char *argv[])
{
    char c;
    while (--argc > 0 && (*++argv)[0] == '-')
        while ((c = *++argv[0]))
                /* code */
    return 0;
}


Seriously, /prog/, seriously? IMO the following is much clearer, although obviously much longer:

#include <stdio.h>

int main(int argc, char *argv[])
{
    char c, *s;
    int i;
    for (i = 1; i < argc; i++) {
        s = argv[i];
        if ((c = *s) == '-')
            while ((c = *++s))
                /* code */
        else
            break;
    }
    return 0;
}


Which do you prefer?

Name: know your punctuation 2010-09-16 22:52

>>15
Parenthesis, paren is also acceptable.

() - parenthesis (sing. parenthesis) or parens (sing. paren)
[] - brackets ("square brackets")
{} - braces ("curly braces", "curly brackets")
# - number sign (pound sign, hash, crosshatch, octothorpe)
" - quotation mark (double quote)
' - apostrophe (single quote, "prime")
    NOTE: prefer U+2018-U+201F where possible instead of
          double and single quotes, or U+2032-U+2034 as
          [double/triple] prime, minutes, seconds, feet, and
          inches
& - ampersand (and)
* - asterisk (times)
    NOTE: U+00D7 and U+2A2F are multiplication operators,
          and an "asterisk operator" is available at U+2217
/ - slash (solidus, virgule, "stroke")
    NOTE: U+2215 is a more specific division sign but
          it is not necessary.
` - grave accent ("backtick")
    NOTE: not generally acceptable as an opening single quote
          (that is, except in TeX)
| - pipe (vertical line, vertical bar)
    NOTE: box drawing characters are also available
          starting at U+2500
~ - tilde
< - less than
- greater than
    NOTE: prefer U+2329 and U+232A as angle brackets,
          where possible
- - hyphen
    NOTE: prefer U+2010-U+2015 for dashes, and prefer
          U+2212 for minus signs.  An en dash is an
          acceptable substitute for a minus sign.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List