const char *pointerStr[]=
{
"BEST123, ", // 0x00
"Best2233, ", // 0x01
"ABCDEFGH, ", // 0x02
"123456, ", // 0x03
"helloworld, " // 0x04
};
typedef struct
{
char value;
char name[40];
}StrInfo;
typedef struct
{
int regMax;
StrInfo info[60];
} structNew;
void main()
{
int i;
structNew pret;
for ( i=0;i<5;i++)
{
printf("PointerStr size of %dth %d \n",i,sizeof(pointerStr[i]));
printf("pret size of %dth %d \n",i,sizeof(pret.info[i].name));
}
}
Run Code Online (Sandbox Code Playgroud)
以上程序产生的结果
PointerStr size of 0th 4
pret size of 0th 40
PointerStr size of 1th 4
pret size of 1th 40
PointerStr size of 2th 4
pret size of 2th 40
PointerStr size of 3th 4
pret size of 3th 40
PointerStr size of 4th 4
pret size of 4th 40
Run Code Online (Sandbox Code Playgroud)
如果我想知道PointerStr中每个字符串的大小,那么如何找到它?是否只能使用strlen?我们还有其他方法吗?这个可变长度数组如何存储在内存中?结果是becoz指针指针变量是指针变量,它的大小总是4.如果我错了,请纠正我.