Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have read the book. It does not teach you C. It assumes that you know the language. It does not teach you anything about the syntax of the language.

He does not tell you how to log into a UNIX system. He tells you what happens when you log into a UNIX system. (That is a big difference. Compare the first chapter of Kerrigan and Pike's The Unix Programming Environment, which actually does teach about terminals and explicitly talks about how to log in and what a login is -- for a complete beginner.)

Here's the first bit of code, from page 5:

    #include "apue.h"
    #include <dirent.h>
    
    int
    main(int argc, char *argv[])
    {
    	DIR		*dp;
    	struct dirent	*dirp;
    
    	if (argc != 2)
    		err_quit("usage: ls directory_name");
    
    	if ((dp = opendir(argv[1])) == NULL)
    		err_sys("can't open %s", argv[1]);
    	while ((dirp = readdir(dp)) != NULL)
    		printf("%s\n", dirp->d_name);
    
    	closedir(dp);
    	exit(0);
    }
My point is very simple: If you do not know C and especially if you also do not know any programming language, it would require either magic or another book or tutorial to figure out the syntax or semantics of those lines. Why is the first include thingy in quotes and the second in brackets? What is an include thingy anyhow? What is DIR? Why do some things have a * in front of them? When are semicolons used? Not every line ends in one, but most do - why? What is the -> used for? When do I use parentheses and when do I use braces? What is argc or argv? Are those names important? What is NULL? Why are some things all capitals and some not. Does that matter? He doesn't answer any of these questions (nor should he), because the book is not meant to teach you C. It assumes that you already know C.

It is not a beginner's book.



Here's a bit of code from page 10:

  #include "ourhdr.h"

  int
  main(void)
  {
    printf("hello world from process ID %d\n", getpid());
    exit(0);
  }
Ch 7 is the environment of a unix process. 7.2: "argc is the number of command line arguments and argv is an array of pointers to the arguments. We describe these in Section 7.4." exit codes are discussed in section 7.3, where he also talks about 0 in exit.

Granted, he does not discuss the syntax or NULL...

Looking through it.. I'll agree it isn't a beginner book. Intermediate at worst though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: