#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%d\n", argc);
}
使用GCC编译这个简单程序主(INT ARGC,CHAR *的argv [])给出奇怪的结果*作为命令行参数
[email protected]:~/KANDR$ ./a.out
1
[email protected]:~/KANDR$ ./a.out 13 432
3
[email protected]:~/KANDR$ ./a.out 13 432 +
4
[email protected]:~/KANDR$ ./a.out 13 432 + *
112
[email protected]:~/KANDR$ ^C
为什么最后一个命令返回112,当我有*
作为命令行参数?
你可以通过修改代码来打印参数以及ARGC已经调试自己这一点。然后你会看到麻烦是什么。 ('for(int i = 0; i