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));
}
}
의 가변 길이 배열 위의 프로그램에 대한 메모리 맵은 크기는 어떻게됩니까? 문자열
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
그때 어떻게 그것을 찾기 위해 각각의 크기와 PointerStr의 모든 문자열을 알고 싶다면
의 결과를? strlen을 사용하는 것만 가능합니까? 다른 방법이 있니? 이 가변 길이 배열을 메모리에 저장하는 방법은 무엇입니까? 결과는 pointerStr이 포인터 변수이고 그 크기가 항상 4 인 becoz입니다. 제가 틀렸다면 수정하십시오.
보통 0으로 끝나는 문자열의 경우 'pointerStr ''strlen'을 사용해야합니다. –
코드에 가변 길이 배열이 없습니다. 모두 컴파일 타임에 고정됩니다. –