1) QUESTION IS: how can a pointer be NULL or 0 when it's an adress wich gives a value? Because, as I understand it to be like this:
Expression----------------Type--------------Value p-------------------------pointer-to-double--an adress *p------------------------double-------------(12.34)Or, is it saying that when declaring p = NULL;, the adress of that pointer is 0x00000000 and there is no value stacked in this pointer?
Also, when do you use this?
A zero in pointer context or the macro NULL will both be compiled as the value of a null pointer constant. (You don't set a pointer variable's address.)
When to use it? Some like to set a pointer to NULL after freeing dynamically allocated memory so that the pointer could be checked for NULL to see if previously allocated memory has been freed.
[edit] http://www.eskimo.com/~scs/C-faq/s5.html
2) Can someone explain what the use is of typedef and how I can interpret this explanation?
When this is declared: typedef char *pointer
the pointer becomes an indication of the type char*. This means that the following two declarations are equivalent: char *p; pointer p;
I find this to be the worst use of typedef -- hiding a pointer declaration. It is intended to be like this.
typedef char *pointer;
char *p, *q;
pointer p, q;
Because if you did the following, it wouldnot be the same.
char* p, q;
pointer p, q;
Even though it might appear to be. But I find typedefing pointers to be obfuscatory.
I'm sure Narue will have a better slant on this as well.