POINTER
- Michael Felix

- Dec 18, 2018
- 1 min read
A pointer is a variable that points to another variable memory address.
A pointer does not contain a data value as well as an ordinary variable, the pointer variable contains an address.
By using pointers, we can connect various variables where when a variable is changed, other variables that are connected also change.
Declaration of pointer variables as well as other variable declarations is only added to "*" in front of variable names.
int *xTo get the address of the memory pointer (address of), the command used is to add a sign "&" in front of the variable
&xTo get the contents or values of a pointer variable, the command used is just the name of the variable.
xTo get the contents or values from the address contained in the contents of the pointer (value pointed by), the command used is to add a "*" sign in front of the variable
*xExample
#include<stdio.h>
#include <conio.h>
int main ()
{
int value [3], * pointer;
value of [0] = 125;
value [1] = 345;
value [2] = 750;
pointer = & value [0];
printf ("% i value is in memory address% p \ n", * pointer, pointer);
printf ("% i value is in memory address% p \ n", * (pointer + 1),
pointer + 1);
printf ("% i value is in memory address% p \ n", * (pointer + 2),
pointer + 2);
getchar ()
return 0;
}
Comments