top of page
Blog: Blog2

POINTER

  • Writer: Michael Felix
    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 *x

To get the address of the memory pointer (address of), the command used is to add a sign "&" in front of the variable

&x

To get the contents or values ​​of a pointer variable, the command used is just the name of the variable.

x

To 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

*x

Example

#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;
}
 
 
 

Recent Posts

See All
IF CONDITON

An if structure is formed from an if statement and is often used to select a single condition. If the selected process is fulfilled or...

 
 
 
Struct

Struct is a formed data type that contains a collection of variables that are in the same name and are related to one another. In...

 
 
 
Array

An array is a collection of data values ​​of the same type in a certain order that uses the same name. According to its dimensions,...

 
 
 

Comments


  • instagram
  • generic-social-link

©2018 by systemnotfound. Proudly created with Wix.com

bottom of page