Skip to main content

Posts

Showing posts from April, 2014

C Pointer A cup of tea... :)

What are Pointers? Different from other normal variables which can store values, pointers are special variables that can hold the address of a variable. Since they store memory address of a variable, the pointers are very commonly said to “point to variables”. Lets try to understand the concept. As shown in the above diagram: A normal variable ‘var’ has a memory address of 1001 and holds a value 50. A pointer variable has its own address 2047 but stores 1001, which is the address of the variable ‘var’ How to Declare a Pointer? A pointer is declared as : <pointer type> *<pointer-name>   In the above declaration : pointer-type : It specifies the type of pointer. It can be int,char, float etc. This type specifies the type of variable whose address this pointer can store. pointer-name : It can be any name specified by the user. Professionally, there are some coding styles which every code follows. The pointer names commonly start with ‘