AD1

Wednesday, 22 February 2017

find the output

what will be the output of the following code 


#include <stdio.h>
int main(void) {
int x=100;char y=3;float z=3.12;
int *xp=&x;char *yp=&y;float *zp=&z;
printf("%d\t%d\t%d\t%d\t%d\n",sizeof(NULL),sizeof(xp),sizeof(yp),sizeof(zp),sizeof("clu"));
return 0;
}
view raw szp.c hosted with ❤ by GitHub
output will be 
8  8  8  4
size of a pointer to any data type is type independent , size of pointer depends on your machine address bus.
sizeof("clu")  here "clu" is treated as array of characters ={'c','l','u','\0'}
so sizeof("clu") is 4 bytes

No comments:

Post a Comment