#include<stdio.h>
#include <stdlib.h>
int main() {
char *a = malloc(sizeof(int) * 18);
printf("%d",sizeof(a));
}
What is the size of a gonna be on a 32-bit system?
I tried it on a 64-bit system and a was 8. Will it be the same on a 32-bit system?
CodePudding user response:
"32 bit" refers to the maximum data size that the CPU can execute in a single instruction. This actually has no relation at all to the address bus of the same CPU, so a question asking "how large is an address on a 32 bit CPU" can't be answered.
For example most 8 bit CPUs on the market have 16 bit address buses. And many 8/16 bitters even support 24 bit or larger address buses.
Although as it happens, the vast majority of 32 bit CPUs on the market conveniently also have 32 bit address buses. But this is no guarantee unless you have a specific CPU in mind.