변수 포인터와 포인터, 포인터 포인터 및 포인터 포인터를 저장하는 데 사용되는 주소의 크기를 이해하려고했습니다. 그 결과는 다소 혼란 스럽습니다.이 간단한 포인터 프로그램 출력에 대한 설명은 무엇입니까
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main(void)
{
char *** ppptr_string = NULL;
int *** ppptr_int = NULL;
double *** ppptr_dbl = NULL;
char c=0; int i=0; double d=0;
printf("\n %d %d %d %d %d\n", sizeof(&ppptr_string),
sizeof(ppptr_string), sizeof(*ppptr_string), sizeof(**ppptr_string),
sizeof(***ppptr_string));
printf("\n %d %d %d %d %d\n", sizeof(&ppptr_int), sizeof(ppptr_int),
sizeof(*ppptr_int), sizeof(**ppptr_int), sizeof(***ppptr_int));
printf("\n %d %d %d %d %d\n", sizeof(&ppptr_dbl), sizeof(ppptr_dbl),
sizeof(*ppptr_dbl), sizeof(**ppptr_dbl), sizeof(***ppptr_dbl));
printf("\n sizeof(char) = %d, sizeof(int) = %d, sizeof(double) = %d",
sizeof(c), sizeof(i), sizeof(d));
printf("\n sizeof(&char) = %d, sizeof(&int) = %d, sizeof(&double) = %d",
sizeof(&c), sizeof(&i), sizeof(&d));
getch();
return 0;
}
이제 혼란 : 여기
는 코드입니다. 가변 주소는 항상이 기계에서 2 바이트 길이임을 알 수 있습니다. 변수의 유형과 상관없이 포인터 변수의 유무에 관계없이 하지만 왜 여기에 많은 항목이 들어서서 크기가 4가 될까요? 포인터는 크기에 관계없이 항상 크기가 4입니다. 변수가 저장되는> < 주소는 크기가 2입니다. 가리키는 내용은 유형에 따라 크기가 있습니다.출력 크기가 4 인 이유는 무엇입니까 ?? 볼랜드 C에서
내 출력 ++ 당신이 유형 T
및 T*** ptr
같은 포인터에 대한 포인터가있는 경우 5.02
conio.h? 이것은 MS-DOS 컴파일러입니까? – src
4 세가 나올 때 나 2 세가 나올 때 나는 얻지 못하는만큼 나눠주세요. –
만약 포인터 크기가 4라면, 포인터의 종류는 당신의 컴퓨터에서 4 바이트입니다. 언어 표준은 포인터가 어떤 크기인지 말해주지 않습니다. –