自己写得简易WC.c可以帮助理解
initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE);
atexit (close_stdout);
/* Line buffer stdout to ensure lines are written atomically and immediately so that processes running in parallel do not intersperse their output. */ setvbuf (stdout, NULL, _IOLBF, 0);
print_lines = print_words = print_chars = print_bytes = false; print_linelength = false;
total_lines = total_words = total_chars = total_bytes = max_line_length = 0;
while ((optc = getopt_long (argc, argv, "clLmw", longopts, NULL)) != -1) switch (optc) {
case 'c':
print_bytes = true; break;
case 'm':
print_chars = true; break;
case 'l':
print_lines = true; break;
case 'w':
print_words = true; break;
case 'L':
print_linelength = true; break;
case FILES0_FROM_OPTION: files_from = optarg; break;