| title | layout | nav_order | parent |
|---|---|---|---|
Source code and Git repository |
default |
2 |
Home |
- Create a github repo
- Install wsl: https://learn.microsoft.com/en-us/windows/wsl/install
- Install Vscode: https://code.visualstudio.com/
- Clone your repository
- Reopen in WSL
git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"sudo apt-get install build-essential clang-format- Create the file
pointers.cppand paste the following code:
#include <iostream>
using namespace std;
int main() {
int x = 10;
int* p = &x; // Pointer to x
cout << "Value of x: " << x << endl; // Output: 10
cout << "Address of x: " << &x << endl; // Output: Address of x
cout << "Value at pointer p: " << *p << endl; // Output: 10
cout << "Address stored in pointer p: " << p << endl; // Output: Address of x
*p = 20; // Change value at pointer p
cout << "New value of x: " << x << endl; // Output: 20
return 0;
}- Open a terminal (Ctrl-ñ) and compile the file:
g++ -std=c++20 -o pointers pointers.cppThis will create the file pointers (the executable!). To run it:
./pointers