歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

about argc and argv

what is the meaming of it !



[8279 0] %
cat foo.c

#include

int main(int argc, char *argv[])
{
int i;

printf("argc = %d\n", argc);
for (i = 0; argv[i]; i++) {
printf("argv[%d] = '%s'\n", i, argv[i]);
}

return 0;
}

[8279 0] %
gcc foo.c
[8279 0] % ./a.out
argc = 1
argv[0] = './a.out'
[8279 0] % ./a.out 1 2 3
argc = 4
argv[0] = './a.out'
argv[1] = '1'
argv[2] = '2'
argv[3] = '3'
[8279 0] % ./a.out hello world
argc = 3
argv[0] = './a.out'
argv[1] = 'hello'
argv[2] = 'world'

Copyright © Linux教程網 All Rights Reserved