(Created page with "In C language a pointer is just a normal data type that can hold a address. There is just two operators a programmer should know about pointer usage &var => returns the addr...")
 
Line 5: Line 5:
 
  *var => returns the content of value of var  
 
  *var => returns the content of value of var  
 
  (it takes the value of var as address and returns the value of that address)
 
  (it takes the value of var as address and returns the value of that address)
 +
 
  var => returns the value of var
 
  var => returns the value of var
  

Revision as of 09:23, 8 December 2013

In C language a pointer is just a normal data type that can hold a address.

There is just two operators a programmer should know about pointer usage

&var => returns the address of var
*var => returns the content of value of var 
(it takes the value of var as address and returns the value of that address)
var => returns the value of var
A pointer can hold any address (any int value can be considered an address), but the programmer should ensure that the address is within the memory range allocated to the process, or otherwise a segmentation fault can occur. Two normal ways of doing this is 
p = &var1;

In C language a pointer is just a normal data type that can hold a address.

There is just two operators a programmer should know about pointer usage

&var => returns the address of var
*var => returns the content of value of var 
(it takes the value of var as address and returns the value of that address)
var => returns the value of var
A pointer can hold any address (any int value can be considered an address), but the programmer should ensure that the address is within the memory range allocated to the process, or otherwise a segmentation fault can occur. Two normal ways of doing this is 
p = &var1;