Introduction to pointers in C/C++

mycodeschool · 1.6M views · 2013 · 10:07

Open on YouTube

C, C++, Rust, Go & systems languagesEducation & learningtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when explaining pointers, memory addresses and how variables or arrays are stored in memory, usually in comments and answers about confusing pointer behavior.

Recommended by 1 people across 1 different months, 2017 to 2021.

What it is

A 10-minute beginner tutorial from the mycodeschool channel that introduces pointers in C and C++, covering what a pointer is and how addresses and dereferencing work. It is the first lesson of a longer pointers series and assumes only basic C knowledge.

What people said

Recommends wBB · 2017-12 · Stack Overflow · on “Using long ints with Arduino Uno”

You can see the theory on how to use pointers in many videos on the internet. I researched these two now and I think it might help you: 1) Pointers and arrays [LINK] 2) Programming in c/c++/Arduino [this video]

Cites Enzio · 2017-06 · Stack Overflow · on “How are multidimensional arrays stored in memory?”

I was learning about pointers and multidimensional arrays. I know that they are comprised of several sub arrays arranged one after the other like this. int C[ 3 ][ 2 ][ 2 ]; [LINK] In this example C = 800 This is a pointer to the first array element of the 3 integer array. So, I assume there is a block of memory reserved to store the reference variable C like this [LINK] What I don't understand is how dereferencing work with arrays. In normal context *C mean get the value stored at the address 800. So *C = 2 But here *C would be 800. I understand this logically. This is a pointer to the 2 integer array inside. But how does the compiler understand that? Where are the information about the oth

Cites acekuber · 2018-12 · Stack Overflow · on “How a variable and its reference is stored and accessed in computer memory?”

"take in the left hand the int (4 bytes) value at address 0" How does the compiler know to which address to start from ? Does it maintain a lookup table for this in runtime ? see this video: link [this video]

Cites NaturalDemon · 2021-05 · Stack Overflow · on “To Find factorial of large number(number of digits >20)”

i see some errors: #define MAX 20 void multiply(int x,vector<int> res,int* res_size){ // should be .. void multiply(int x,vector<int> res,int &res_size) int carry=0; for(int i=0;i<*res_size;i++){ int prod=carry+ x*res[i]; res[i] = prod%10; carry = prod/10; } while(carry){ res[*res_size] = carry%10; carry/=10; (*res_size)++; } } vector<int> factorial(int n){ vector<int> res(MAX); res[0] = 1; int res_size=1; for(int i=2;i<=n;i++){ multiply(i,res,&res_size); // should be ... multiply(i,res,res_size) } return res; } total: void multiply(int x,vector<int> res,int &res_size){ cout << &res_size<< endl; // print address of "res_size" int carry=0; for(int i=0;i<res_size;i++){ int prod=carry+ x*res[i]