我正在阅读这本书Windows 系统编程。第二章有一个程序Cat.c。它实现了catlinux的命令。代码是http://pastebin.com/wwQFp599
这是让我感到困惑的部分:
/* iFirstFile is the argv [] index of the first input file. */
iFirstFile = Options (argc, argv, _T("s"), &dashS, NULL);
if (iFirstFile == argc) { /* No files in arg list. */
CatFile (hStdIn, hStdOut);
return 0;
}
如评论iFirstFile中所述argv [],是第一个输入文件的索引。
这意味着如果我尝试cat -s abc.txt,那么iFirstFile = 2,但是argc == 3。
我想不出在什么情况下iFirstFile == argc?我无法理解其背后的逻辑。谁能解释一下这部分?