This is a question in reference to this question: What does (char *)0 mean in C?
There the answers slightly deviated away from explaining what exactly the answer was, but the final answer mentioned that it was a pointer to a character at address 0 and that it was null. This brought up two doubts for me:
In C, can I have
char* 9
and say that it is a pointer to address 9? Won't I get an error or a warning?Let's say that
(char*) 0
is indeed a pointer to character at address 0, what does this address 0 mean? I mean how can we say it's a null? In that case what would the value of(char*) 1
,(char*) 2
, etc. be?
Context: I initially searched for an answer to this question when I figured the last argument in the user-space wrapper execl
would be null but instead I saw a rather odd looking syntax for it, i.e., (char *) 0
.
char *p = (char *)9;
(without warnings), but you can not dereference it, take a look to c-faq.com/null – Achieve0
, a null-pointer is actually system dependent. However, the integer zero when casted to a pointer (any pointer really) is converted by the compiler to the system-dependent null-pointer. – Slapjack