//argv_test.c
#include<stdio.h>
int main(int argc,char **argv)//指向字符串的指针
{
unsigned int a;
unsigned short uchar[2];
uchar[0] = *argv[1];
uchar[1] = *argv[2];
a= atoi(argv[1]);
printf("a = %d *argv[1] %c *argv[2] %c argc=\n",a,*argv[1],*argv[2],argc);
return 0;
}
gcc -o argv_test argv_test.c
./argv_test 1 2
打印输出 a=1 *argv[1]=1 *argv[2]=2;argc=3;
argc为输入参数个数,**argv中为输入的字符串内容,**argv是一个指向字符串的指针,其大小没有固定,可以换成另一种格式*argv[].