#include "stdafx.h"
#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a[2][4]={1,2,3,4,5,6,7,8};
int *i[2]={a[0],a[1]};
cout<<"i[0]:"<<i[0]<<endl;
cout<<"*i[0]:"<<*i[0]<<endl;
char s[][10]={"hello","world","C++ test"};
char *p[4]={s[0],s[1],s[2],s[3]};
cout<<"p[0]:"<<p[0]<<endl;
cout<<"*p[0]:"<<*p[0]<<endl;
return 0;
}
运行结果为
可见int型指针数组和char型指针数组的不同。
由此可知main函数中char *argv[]在使用时,argv[0]为exe路径名,argv[1]及以后均为输入参数。argc表示argv数组中的字符串个数。