文章目录
数组
#include <stdio.h>
void print1(char *ptr)
{
}
void print2(char (*str)[100])
{
}
void print3(char (*ktr)[2][100])
{
}
void print4(char **wtr)
{
}
int main()
{
char ptr[100]="hello world";
//ptr:一维数组首元素的地址 ptr + 1----1跳一个字节
//&ptr:一维数组地址 &ptr + 1 ---100字节(跳一个数组长度)
//*(&ptr)=ptr;对一维数组的地址取值等于一维数组首元素的地址
char ktr[3][100]={"hello1","hello2","hello3"};
//ktr:二维数组的首个一维数组的地址
//&ktr:二维数组的地址
//*ktr:二维数组的首个一维数组的首元素地址
//**ktr:二维数组的首个一维数组的首元素的值
//*(&ktr)=ktr:对二维数组取值等于二维数组中首个一维数组的地址
char str[2][2][100]={{"hello4","hello5"},{"hello6","hello7"}};
//str:三维数组中首个二维数组的地址
//&str:三维数组的地址
//*str:三维数组中首个二维数组的首个一维数组的地址
//**str:三维数组中首个二维数组的首个一维数组的首个元素的地址
//***str:三维数组中首个二维数组的首个一维数组的首个元素的值
char *wtr[3]={"hello8","hello9","hello10"};
//指针数组实际上还是一个一维数组,只不过里面保存的是指针
//wtr:首个元素的地址
print1(ptr);
print2(ktr);
print3(str);
print4(wtr);
return 0;
}