0 votes 0 votes Can someone explain the output of the following program? Need the logic behind the Output. The Output is: 4 8 1 1 4 8 8 (nil) 0x1 4 Programming in C programming-in-c + – slowpoke asked Apr 27, 2018 slowpoke 1.0k views answer comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments Akhilesh Singla commented Apr 28, 2018 reply Follow Share 1?NULL:(int*)1 I could be wrong, but this is what I think happened here. This ternary operator evaluates to NULL, which is typecasted to integer because we used "1" in the expression and thus size of integer pointer, which is same as integer, is returned. 0 votes 0 votes slowpoke commented Apr 29, 2018 reply Follow Share For printf("%d", sizeof *(NULL)); I think it gives 1 because we are asking about the size of value stored at NULL, and its size is 1. Whose size is 1? The size of value stored at NULL is 1? How can anything be stored at NULL. From what I understood, sizeOf(NULL), its returning 4, since its returning size of Pointer pointing to NULL. But what is *(NULL) returning? Its de-referrencing a void pointer basically, right? is it a char? Will sizeof *(NULL) always return 1? Also, for the next question: 1?NULL:(int*)1 I could be wrong, but this is what I think happened here. This ternary operator evaluates to NULL, which is typecasted to integer because we used "1" in the expression and thus size of integer pointer, which is same as integer, is returned. But that's not the case here. I tried executing it on a compiler where Pointer, and Integer have different size and Even when the size of Integer Pointer, is not same as Size of Integer, its still returning size of Integer. Have a look: https://ideone.com/YjM1Pj 0 votes 0 votes Akhilesh Singla commented Apr 29, 2018 reply Follow Share Hmm, then my thinking was wrong. Maybe it is compiler dependent. I can't really say for sure. I'm clueless like you now. 0 votes 0 votes Please log in or register to add a comment.