David McClellan <[email protected]> writes:
> printf("Why does this directory not work???: %s\n",argv[2]);
> while(entry = readdir(currentDirectory)) {
BTW, if you want to write this as a while loop, I encourage you to write
this as:
while ((entry = readdir(currentDirectory)) != NULL) {
Style points as follows:
1/ "while" is a keyword, not a function name, and thus has a space after
it (similarly "if", "for", &c.).
1b/ Consistency!
if (stat(entry->d_name, &statbuf == -1)
^
if ((pwd = gwetpwuid(statbuf.st_uid)) != NULL)
^ ^
2/ Eschew the implicit boolean. You are not testing that readdir
happens to return a value that happens to be considered equal to "false"
… you're testing the boolean condition that readdir returns a value not
equal to NULL. So write that. Some might call it splitting hairs, but
the latter is closer to what you actually mean.
3/ Many people go further and say that one should never use the
side-effect of an assignment (value return). I disagree. But note that
many people do say this, as many find it confusing. Caveat writer.
4/ Tabs are always spaces … but 8 spaces is a bit excessive. ;)
--
...jsled
http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo $...@${b}