#include
void main(int argc , char * argv[])
{
printf("%s\n",*(argv++));
}
The above program is correct,but the following cannot pass compiling.
#include
void main()
{
char* arr[2] = {"first","second"};
printf("%s\n",*(arr++));
}
Compare the two program,we know that the array parameter of a function is treated as a pointer,so it can be changed using "++" operator.
int a=1,b=2;
int* intArr[2] = {&a,&b}; //intArr is an array containing two int* pointers.
printf("a=%d,b=%d\n",**intArr,*(intArr[1]));
int arr[2];
int (*intPtr)[2] = &arr; //intPtr is a pointer which points to a 2-dimension array.
printf("%d",(*intPtr)[0]);
没有评论:
发表评论