#include <stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
int a[10] = { 1,2,3,4,5,6,7,8,9,10 };
int(*p)[10]; //先算小括号,p和*结合,属于指针类型,指针指向拥有十个int型元素的数组
//p=a;等价于int (*p)[10]=&a;
p = &a;
printf("%d\t%d\n", sizeof(p), sizeof(*p));
printf("%d\n", (*p)[3]);
system("pause");
}
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
char str[3][20] = { "hello","world","itcast" };
char(*p)[20];//行指针,str[3][20]共三行,每行20个字节
p = &str[0];
printf("%s\n", *(p + 1));//+1==向后走了20个字节,因为每个单词五个字母
system("pause");
return 0;
}
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
char str[3][20] = { "hello","world","itcast" };
//char(*p)[20];//行指针,str[3][20]共三行,每行20个字节
char *p;
p = str[0];
printf("%s\n", (p + 1));//+1==向后走了20个字节,因为每个单词五个字母
printf("%s\n", (p + 20));//+1==向后走了20个字节,因为每个单词五个字母
system("pause");
return 0;
}