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 old book probably, careful!


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -