c - Why is the output of this code is 4? -
i using sizeof function calculate size of string. should have printed 2.but why 4? here code.
#include <stdio.h> #include <string.h> void main() { char *b = "ab"; printf(" %d ",sizeof(b)); //printf("%s ",b); }
because on platform pointers 4 bytes. or 32bit if prefer.
note: using void main()
signature main()
indicates studying c old book probably, careful!
Comments
Post a Comment