John Mavrick's Garden

Search IconIcon to open search

Last updated Unknown

Status: Tags: Links: C MOC


Pointers and References

Pointers

Uses

Syntax

& to get adress of a value * access value at the adress

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
int* px = &x; //create pointer var to adr of x

*px = 7; //value at var px is changed to 7

int x = 5; int* px = &x; // pointer to location x
//int* is a type 
printf("The address in memory of %d is %p|", x, px); 
>> The address in memory of 5 is 0x9a58af3c4 
// %p is a pointer and address is usually in hexadecimal

Questions

Image from Gyazo ? a = 7, b = 1, c = 2


Backlinks


References:

Created:: 2021-09-13 14:35


Interactive Graph