Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c pointers

// Variable declaration
type var;

// Get the address (a pointer to) a variable
// &var   ->   type*

// Pointer declaration(s)
type* ptr_a;
type* ptr_b; 

// Change what pointer is pointing to 
ptr_a = &var;
ptr_b = ptr_a;

// Can declare and assign in 1 line
type* ptr_c = &var;
type* ptr_d = ptr_c;

// "Pointers" are also variables
// &ptr_d   ->   type**
type** ptr_e = &ptr_d;

// Getting values from pointers
// *ptr_d   ->   type
// *ptr_e   ->   type*
type value = *ptr_d; 
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #pointers
ADD COMMENT
Topic
Name
7+8 =