Why does it prints that the size of char is 4 byte? [duplicate]

时光毁灭记忆、已成空白 提交于 2020-11-29 21:06:44

问题


In this program I have located char pointer. I have located 1 byte of memory in heap. But when I print its size it shows 4 bytes. please help.

//CODES//

#include <stdio.h>
#include <stdlib.h>
int main(){
char *ptr;
ptr=(char*)malloc(1);
printf("The size is %d.",sizeof(ptr));
}

来源:https://stackoverflow.com/questions/64962528/why-does-it-prints-that-the-size-of-char-is-4-byte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!