I was messing around in C trying to find a way to interpret the difference in memory address' when finding two array elements next to each other and finding the difference. Here's my code:
#include <stdio.h>
int main(){
char *a[5];
printf("%p\n", (&a[0]));
printf("%p\n", (&a[1]));
return 0;
}
And example output:
0xbf9343dc
0xbf9343e0
When doing this, shouldn't the output be something to the form:
0x0....0
0x0....1
Because the size of a char pointer should be 1 (on a 32-bit system which I am using).
If anyone knows why this is the case and can offer an explanation it would be very helpful
The size of a char is 1, the size of a char * is implementation dependent, usually 4 in 32-bit system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With