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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -