C Pointers

C supports pointers , a type of reference that stores memory address of any identifier or function. Pointers can be dereferenced to access data at which pointer points to. size of pointer depends on architecture of machine. 32 bit machine has pointer size as 4 byte , similiary 64 bit machine has pointer size as 8 byte. Pointers are used for many purpose in c. To allocate Dynamic memory pointers are used. To implement tree data structures pointers are used. There are many applications of pointers in C.

A null pointer value does not refers to any address location. Dereferencing a null pointer is not defined, It will harm your program and often results to segmentation fault.

A void pointer points to a identifier whose type is not specified. Thus the size and type of the void type variable is not known so void pointers cannot be dereferenced. Simply they can be converted to other type of identifier or object.

Declaration of pointer :

data_type  *pointer_var_name ;

e.g. :

To define integer pointer :

Initialization of pointer :

Pointer to array :