1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
int main() {
int x = 42;
int* ptr = &x; // 'ptr' is a raw pointer to 'x'
std::cout << "Value of x: " << x << std::endl;
std::cout << "Value pointed to by ptr: " << *ptr << std::endl;
*ptr = 100; // Modify the value of 'x' through the pointer
std::cout << "New value of x: " << x << std::endl;
return 0;
}
Back to raw_pointers