char a[]="hello";
char *p=a;
printf("%d",sizeof(p));
The expected output is 4 or 8 but the output we get is 2.
Using TurboC3
char a[]="hello";
char *p=a;
printf("%d",sizeof(p));
The expected output is 4 or 8 but the output we get is 2.
Using TurboC3
I'd highly recommend "Assembly Language: Step by Step by Jeff Duntemann" (not the whole book, just the memory models' section).
Size of pointer depend on how much memory it has to address. You're expecting four bytes, that is 32 bits and it can address 4 Gigs of memory. When you'll do some research, you'll find that there was no 4 Gig memory in any personal computer at the time Turbo C was developed (eighties).
As there were no rams of that capacity (maximum was a few megabytes), and even after that, most of the aplications were too "lightweight" (for backward compatibility) for the newer x86
CPUs and high-end hardware (including memory, of course), applications were given a part of that memory (64k for turbo c as stated by @Nadim). So, why bother making a pointer 4 bytes in size when you already know it's never going to use those last 2 bytes.