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:
Seriously, /prog/, seriously? IMO the following is much clearer, although obviously much longer:
Which do you prefer?
// 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?