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: Anonymous 2010-09-17 2:55

>>18
Isn't missing the real issue the whole reason this board exists?
That, and haxing anuses

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