I know you'll never see this, but I just wanted to say that no amount of "thank you's" from me will ever be enough to convey the gratitude I have for your tutorials nor will they ever equal what you've done for us through your concise teaching.
@@JJ-nv6nl & gives the address of memory of the first element of array. But in array we can also get address of array by the array name . Pointer * is used to dereference (means to get data of array) .
@@AdarshKumar-mf3ls thank you for answer, but what I don't understand is this: in 1-D array (let it name B) when we want adress of a first element we use &B and for value *B. But in 2-D array when we use *B we get adress of first element instead of value(like in 1-D array). Can you explain me why please?
Your videos are very clear and informative, more-so than any other written article or video I've looked at regarding this subject specifically. Much appreciated !
I was lucky enough to stumble in his videos through Free Code Camp. This guy is one of a kind, he manages to both explain a notoriously tricky subject in a simple way THAT is also understandable. I truly hope he is doing good in life, he deserves it. Regarding the passing of multi-dimensional arrays in functions, it seems abit hard-coded that you need to specify the dimensions of the array and can't do it truly flexible.
i dont have words to appreciate your lectures. I was so confused about the 2 dimensional array and pointer thing. I even read Dennis Ritchie book but all of them failed to clear my doubts when finally i saw ur videos and i got enlightened with such a tremendous knowledge.. Thanku sir..u r just awesome
Sir, no one can explain pointers in a better way than you did. I literally pray you sir. Please please keep more videos on the basics of programming. How stuff works in memory etc etc. I think many would lack the same. But knowing it would definitely make one a rather more beautiful programmer
well i cant believe that i have reached to this 11thh lesson of pointers by his book.......i hated pointers so much that it is unbelievable for me to even imagine digging deep in the concept....Thanks to mycodeschool his explain of things are awesome and simple.
Truly amazing, I never used to get pointers, it has always baffled me. But now I have a good understanding of it. Thank you so much :D. Hopefully I can manipulate pointers better now.
You are Awesome ..Electronics engineer ...like to understand the things deeply how it works ..You are the only i got on utube with such a nice explaination..thanx brother its really helpful..
16:21 You are not 100% correct here. We can use void Func(int** A) for processing int B[2][3] but via auxiliary steps: int* p[] = {B[0],B[1]}; and int** pp =p;. So we pass Func(pp);
Thanks for these awesome tutorials. Just one thing, I have tried assigning B directly to an integer pointer without using the parenthesis with the pointer variable and it works fine, it does not produce any compilation error.
man you are the best.....i have been watchin this playlist from the beginning and it has just been awesome.... please upload beginner classes on python , javascript etc..
Sad to hear your story sir. I know why you can't make videos any more. Still thanks for your existing videos. You guys were legendary to the whole programming community.
I can't believe c/c++ programming books does not show the multidimensional array used practically for function use, I never realized it could be so complex like this. Declaring multidimensional array is easy, making use out of them from functions is mind twisting.
Can someone explain, why char** argv works? In the video it is said that int** A won't work. As far as I can say, the "3" in "A[ ][3]" is important to let the compiler know the size of the arrays. That way, pointer arithmetic will work. But how comes that "argv++" is a valid instruction (for example if you use getopt())?
Actually, if you think about it, a 2D array can be sent as a pointer to pointer in C/C++. If what you've said is true, then, "int main(int argc, char **argv)", would never work. Read this: stackoverflow.com/questions/8767166/passing-a-2d-array-to-a-c-function?noredirect=1&lq=1 Apart from that, I think your video is really great to understand the concepts of multidimensional arrays :)
only possible, when you have declared a pointer array. your argument related "int main(int argc, char **argv)" is totally wrong. or perhaps you can pass parameters it like (datatype * )arg .
the expression *(*(b+i)+j) gives different byte values each time its being compiled, how to verify if its true? 6:44 by the way , thanks for the videos,
I want to know, why cant we use **p for a 2D array and ***p for a 3D array. I think it should work...can you please give the technicality associated with this.?
Whatever you've pointed out is true and it does work. Read about it, in this link :- stackoverflow.com/questions/8767166/passing-a-2d-array-to-a-c-function?noredirect=1&lq=1
Sir your videos are very good. I have one doubt. I want to read a matrix from user and then pass it to a function. While writing code the dimension of that matrix will be unknown. Dimensions will be decided by the user. Let size is mXn. Can i use A[][n] to receive the matrix to the function.
bineesh mathew Passing Multidimensional arrays as function argument in C/C++ is tricky. Watch these videos to understand this concept better. th-cam.com/video/sHcnvZA2u88h/w-d-xo.htmlttps://th-cam.com/video/_j5lhHWkbnQ/w-d-xo.html
mycodeschool in the discussion not mentioning about 2D array that read from a user. in that case size of column and row will be unknown. in such case how we can pass it?
B - pointer to first in element inside B[n][m] *B - pointer to first element inside array B[0] If you want to get the value of element B[0][0], you should use *(*B)
int a[5] = {2,4,5,8,1}; int *p; p= a; print a; //200 print *a; //2 sir ne pehle wale video me bola ki pointer name ke aage * lagane se dereference hota h n value return karta h. but is wale video me 4:00 sir bol rhe h ki *baddress print karega matlab output 400 aayega . koi explanation de payega? @mycodeschool
it is the 2-d array. so you need to add one more * to get the value. and it would be like **b which is equal to *b[0] or b[0][0] these are all same. *b = b[0] = &b[0][0] = b (period) will give you the same address
Looking at the picture it seems that there's three 4-element arrays. The 2-element arrays are not emphasised enough in my opinion. That's my only criticism; the rest is awesome as always.
My friend, you do have advance knowledge in C; but the way you are explaining in the video doesn't focus on a larger audience. Why don't you just simply use matrix memory address to explain multi-D arrays to make it easier rather than in a complex one block of memory location. Remember, not everyone has a degree in computer science while learning C in youtube. But I truly appreciate your videos.
Hi Josh, We want to keep our videos as simple as possible. May be showing a 2-D memory block would have been better, but the idea here was to show how exactly 2-D arrays are stored in memory and interpreted during pointer manipulation. Memory should always be looked upon as a 1-D array of bytes. Anyway, i take your feedback. :)
Sir, I salute your dedication to sharing the knowledge, I request you to do the same in the future.So that the student community can get helped with your knowledge.
this statement int (*p)[3]=B didnot work well on my compiler is this statement int (*p)[3] like we are creating an array of pointers and so initialising an array this way didnot work or is this instruction int (*p)[3] compiler specific or is it neither way ...
Think of it as like this. for each * you are gonna replace a + so c[0][1][1] = *(c[0][1] + 1) = *(*(c[0]+1) + 1) = *(*(*(c+0)+1)+1). So if you wanna get value in a c[10][20][30] say you want c[9][15][23] you can do it like c[9][15][23] = *(c[9][15] + 23) = *(*(c[9]+15)+23) = *(*(*(c+9)+15)+23) and &c[9][15][23] = (*(*(c+9)+15) + 23) (without first *)
+Lokesh k hello, first of all, you need to understand that c[0] points to the first adress with the values (2,5)(7,9) witch both are arrays too, so if you look at c[0][0] you are getting a pointer to (2,5) the value 2 being on position 0 and the value 5 being on position 1, so when u have c[0][0][1] its pointing to the adress of 5, and because the expression is being dereferenced by the star, it returns the value contained on the c[0][0][1] adress .... hope it helped :)
Hi, just a question about the function taking a pointer to a 2D array as argument. You used A[ ][2] as parameter, butwhat if you don't know the size of that array ?
He said that in a video before. p can not be an int-pointer. p has to be a pointer to an array. So we write `int (*p)[3] = b;` to say, that p is a pointer pointing on a int array with the length of 3. Edit: And now we can use this like `int x = p[0][1]` or `int y = *(*(p+0)+1)`.
For A[3][2][2], print A + 1, it should be *A + 16 (size of array [2][2]) but I got + 10. For example, if *A = 500 -> A + 1 = 516 but I got 510. Does someone know about this?
Think of it as like this. for each * you are gonna replace a + so c[0][1][1] = *(c[0][1] + 1) = *(*(c[0]+1) + 1) = *(*(*(c+0)+1)+1). So if you wanna get value in a c[10][20][30] say you want c[9][15][23] you can do it like c[9][15][23] = *(c[9][15] + 23) = *(*(c[9]+15)+23) = *(*(*(c+9)+15)+23) and &c[9][15][23] = (*(*(c+9)+15) + 23) (without first *)
int (*p)[3] =B if I try to something like print (*p)[0] // 2 print (*p)[1] // 3 print (*p)[2] // 6 Now print (*p)[3] should throw me error but this prints 4 why ?
I know you'll never see this, but I just wanted to say that no amount of "thank you's" from me will ever be enough to convey the gratitude I have for your tutorials nor will they ever equal what you've done for us through your concise teaching.
why *B do not give value but address. please help
@@apoorvdixit2856 *B will return pointer to integer because it is multidimensional array. To get value you can again dereference it using **B.
@@AdarshKumar-mf3ls but why don't we use & for that adress instead of *?
@@JJ-nv6nl & gives the address of memory of the first element of array. But in array we can also get address of array by the array name .
Pointer * is used to dereference (means to get data of array) .
@@AdarshKumar-mf3ls thank you for answer, but what I don't understand is this: in 1-D array (let it name B) when we want adress of a first element we use &B and for value *B. But in 2-D array when we use *B we get adress of first element instead of value(like in 1-D array). Can you explain me why please?
Your videos are very clear and informative, more-so than any other written article or video I've looked at regarding this subject specifically. Much appreciated !
I was lucky enough to stumble in his videos through Free Code Camp.
This guy is one of a kind, he manages to both explain a notoriously tricky subject in a simple way THAT is also understandable.
I truly hope he is doing good in life, he deserves it.
Regarding the passing of multi-dimensional arrays in functions, it seems abit hard-coded that you need to specify the dimensions of the array and can't do it truly flexible.
Your voice is just awesome...and so is your way of explaining
i dont have words to appreciate your lectures. I was so confused about the 2 dimensional array and pointer thing. I even read Dennis Ritchie book but all of them failed to clear my doubts when finally i saw ur videos and i got enlightened with such a tremendous knowledge.. Thanku sir..u r just awesome
Sir, no one can explain pointers in a better way than you did. I literally pray you sir. Please please keep more videos on the basics of programming. How stuff works in memory etc etc. I think many would lack the same. But knowing it would definitely make one a rather more beautiful programmer
well i cant believe that i have reached to this 11thh lesson of pointers by his book.......i hated pointers so much that it is unbelievable for me to even imagine digging deep in the concept....Thanks to mycodeschool his explain of things are awesome and simple.
That topic is not that deep. Its just not obvious, in conclusion its really good to get an explanation
For some reason this was kinda hard for me, but after watching this video (and the one before it) 7 billion times, I think I get it. Thank you!
Truly amazing, I never used to get pointers, it has always baffled me. But now I have a good understanding of it. Thank you so much :D. Hopefully I can manipulate pointers better now.
i am so happy :D
"I am good working with multi-dimensional arrays using pointers"
You are Awesome ..Electronics engineer ...like to understand the things deeply how it works ..You are the only i got on utube with such a nice explaination..thanx brother its really helpful..
amazing , after my 4 years of engineering now i am getting this concept in just a 14 min video , thanks alot
Ohh Balle Balle I understand Pointers now . So Happy !!!!!!!!!!!!! Thank you !!!!!!!!!!
Beautiful.. simply cannot make it simpler or cleared... there is so much detail backed into these videos.
Finally, I found who you are. Thanks for your great lectures.
Very clear. You are an excellent teacher. Thanks!
This one is a bit mind-blowing. However, the explanation would have never been better than that. So clear and awesome!
you make me fall in love with pointers
This series is super clutch, thank you so much.
The way you've represented this pointer Playlist, it's hard to believe this was uploaded 8 years ago.
This was helpful. Thank-you for creating this content on C++ pointers and 2D arrays!
16:21 You are not 100% correct here. We can use void Func(int** A) for processing int B[2][3] but via auxiliary steps: int* p[] = {B[0],B[1]}; and int** pp =p;. So we pass Func(pp);
Thanks for these awesome tutorials. Just one thing, I have tried assigning B directly to an integer pointer without using the parenthesis with the pointer variable and it works fine, it does not produce any compilation error.
This is SUPER Clear !!!! Thousands Thanks !!!
man you are the best.....i have been watchin this playlist from the beginning and it has just been awesome.... please upload beginner classes on python , javascript etc..
He cannot. Go google about this guy. The loss has been tremendously ours. :(
@@nishanttiwari3015 No. It is his friend. He now works in google.
Simplemente lo ame!!! nunca había visto alguien que explicará tan bien los punteros!!! ¡Muchas Gracias! ¡Vi todos los videos! je, je
00:28 I love your echo :)
very valuable lesson for gate too..thanx sir..with ur help i am able to solve gate question of C
Sad to hear your story sir. I know why you can't make videos any more. Still thanks for your existing videos. You guys were legendary to the whole programming community.
why he stopped, hope nothing bad happened to him
@@ramzirich2585 His friend(also partner in this channel) died in car accident.
I can't believe c/c++ programming books does not show the multidimensional array used practically for function use, I never realized it could be so complex like this. Declaring multidimensional array is easy, making use out of them from functions is mind twisting.
AT 13:01 , why does c& *c give same value. C is the pointer to the arrays, but *c is the pointer to the pointer to the arrays.
Congratulations from Brazil.
Can someone explain, why char** argv works?
In the video it is said that int** A won't work. As far as I can say, the "3" in "A[ ][3]" is important to let the compiler know the size of the arrays. That way, pointer arithmetic will work.
But how comes that "argv++" is a valid instruction (for example if you use getopt())?
Do more videos like dis sir...u really solved my all probs ..thank you sir 🤗
thank u very much sir. your teaching skill is very good and easy to understand.sorry sir I missed to put like in most of these videos
Best explanation brotha !
sir , at print statement we have to use pointer "p" instead of using multidimension array name(*c replace with *p) i think..?
Good teaching sir....Thank you
Very helpful.
This is pure gold \o/
Actually, if you think about it, a 2D array can be sent as a pointer to pointer in C/C++. If what you've said is true, then,
"int main(int argc, char **argv)", would never work.
Read this: stackoverflow.com/questions/8767166/passing-a-2d-array-to-a-c-function?noredirect=1&lq=1
Apart from that, I think your video is really great to understand the concepts of multidimensional arrays :)
only possible, when you have declared a pointer array. your argument related "int main(int argc, char **argv)" is totally wrong. or perhaps you can pass parameters it like (datatype * )arg .
superb explanation, Thank you so much
really good teaching.. Thank you !
the expression *(*(b+i)+j) gives different byte values each time its being compiled, how to verify if its true? 6:44
by the way , thanks for the videos,
ah its okay, answered at 13:10
you are just awesome.....thanks a ton sir..
really good explanation
very clear xplanation sir
awesome as always..
Thank you 🙂💯
Nice explanation
very informative.
i like your all videos.
pls provide videos on oops in c++
Amazing stuff, thank you so much! :)
These are not just simple words that he is speaking they are diamonds.
Sir which ide ya software are you using
4:00
Excellent!
I want to know, why cant we use **p for a 2D array and ***p for a 3D array. I think it should work...can you please give the technicality associated with this.?
***p will work. It will print the B[0][0][0].
Whatever you've pointed out is true and it does work.
Read about it, in this link :-
stackoverflow.com/questions/8767166/passing-a-2d-array-to-a-c-function?noredirect=1&lq=1
**p is actually a pointer to pointer. What we need to pass is an array containing pointers.
Thank you very much !
please help :( why in 15:34 is false and in 15:48 is ok??
9:50
Sir your videos are very good. I have one doubt. I want to read a matrix from user and then pass it to a function. While writing code the dimension of that matrix will be unknown. Dimensions will be decided by the user. Let size is mXn. Can i use A[][n] to receive the matrix to the function.
bineesh mathew Passing Multidimensional arrays as function argument in C/C++ is tricky. Watch these videos to understand this concept better. th-cam.com/video/sHcnvZA2u88h/w-d-xo.htmlttps://th-cam.com/video/_j5lhHWkbnQ/w-d-xo.html
mycodeschool in the discussion not mentioning about 2D array that read from a user. in that case size of column and row will be unknown. in such case how we can pass it?
it was very helpful for me
in 1D array size had to passed separately. So for a 2D array do we need to pass the number of 1D arrays that are present in 2D array?
what if we do not know the size of the 2-D array, what should we write in argument to pass it
sir its not clear why *B returning 400 ?
*B referencing to base address 400 so it should return 2
pls clear my doubt??
B - pointer to first in element inside B[n][m]
*B - pointer to first element inside array B[0]
If you want to get the value of element B[0][0], you should use *(*B)
can you give me a simple example?
Simple example:
*B = 400
B = 400
*B + 1 = 404
B + 1 = 412
i admire ur work
int a[5] = {2,4,5,8,1};
int *p;
p= a;
print a; //200
print *a; //2
sir ne pehle wale video me bola ki pointer name ke aage * lagane se dereference hota h n value return karta h.
but is wale video me 4:00 sir bol rhe h ki *baddress print karega matlab output 400 aayega .
koi explanation de payega? @mycodeschool
it is the 2-d array. so you need to add one more * to get the value. and it would be like **b which is equal to *b[0] or b[0][0] these are all same.
*b = b[0] = &b[0][0] = b (period) will give you the same address
sir..can u please show the logic needed for multiplication of matrices with n without functions plz
Where can I find some practice questions on pointer arithmetic?
+Mohmmad Ayaz Shaikh geeksquiz.com/c-language-2/pointers/
Is it possible to represent the 3dimensional array in a picture, if possible help me guys with clear explanations and some real time examples as well.
If you need a template, here is a nice one I created that can help you understand better hopefully.
pastebin.com/A28MEwvk
You are awesome
very useful
great explanation ever, thank you very much sir
Looking at the picture it seems that there's three 4-element arrays. The 2-element arrays are not emphasised enough in my opinion. That's my only criticism; the rest is awesome as always.
You are boss!
My friend, you do have advance knowledge in C; but the way you are explaining in the video doesn't focus on a larger audience. Why don't you just simply use matrix memory address to explain multi-D arrays to make it easier rather than in a complex one block of memory location. Remember, not everyone has a degree in computer science while learning C in youtube. But I truly appreciate your videos.
Hi Josh,
We want to keep our videos as simple as possible. May be showing a 2-D memory block would have been better, but the idea here was to show how exactly 2-D arrays are stored in memory and interpreted during pointer manipulation. Memory should always be looked upon as a 1-D array of bytes. Anyway, i take your feedback. :)
Sir, I salute your dedication to sharing the knowledge, I request you to do the same in the future.So that the student community can get helped with your knowledge.
Sir, please don't change your style of teaching because an in depth knowledge of how pointers are stored in the memory is necessary! :)
Excelente
hello sir : i have one question ?
is not c[1][0] = 7,9
you wrote c[0][1] = 7,9
i do not know why ?
Thank you
can't believe I have the same question after 9 years! i was looking for the answer here but it seems I wouldn't
if the **A just won't work, how does **argv work ?
how to delete a particular data set from a 2D array??
this statement int (*p)[3]=B didnot work well on my compiler is this statement int (*p)[3] like we are creating an array of pointers and so initialising an array this way didnot work or is this instruction int (*p)[3] compiler specific or is it neither way ...
We can use void Func(int** A) for processing int B[2][3] but via auxiliary steps: int* p[] = {B[0],B[1]}; and int** pp =p;. So we pass Func(pp);
god bless you inchallah
Sorry I got my answer it was running in a code ,,,he has explained its answer as 800 earlier for our understanding
but for address we use %u right?
this reminds me of the movie Inception
u r awesome :)
in *(c[1]+1) isnt c[1] a 2d array thus c[1]+1 should be c[2] and the ans should be 832?
Think of it as like this. for each * you are gonna replace a +
so c[0][1][1] = *(c[0][1] + 1) = *(*(c[0]+1) + 1) = *(*(*(c+0)+1)+1). So if you wanna get value in a c[10][20][30] say you want c[9][15][23]
you can do it like
c[9][15][23] = *(c[9][15] + 23) = *(*(c[9]+15)+23) = *(*(*(c+9)+15)+23)
and &c[9][15][23] = (*(*(c+9)+15) + 23) (without first *)
can u please explain me once how *(c[0][0]+1)) will gives output as 5
+Lokesh k hello, first of all, you need to understand that c[0] points to the first adress with the values (2,5)(7,9) witch both are arrays too, so if you look at c[0][0] you are getting a pointer to (2,5) the value 2 being on position 0 and the value 5 being on position 1, so when u have c[0][0][1] its pointing to the adress of 5, and because the expression is being dereferenced by the star, it returns the value contained on the c[0][0][1] adress .... hope it helped :)
You can also write it as *(*(*(c+0) +0) +1) or c[0][0][1].
Hi, just a question about the function taking a pointer to a 2D array as argument. You used A[ ][2] as parameter, butwhat if you don't know the size of that array ?
You did not explain, why we cant say, `int b[2][3]; int *p = b;`, excluding the compiler warning
He said that in a video before. p can not be an int-pointer. p has to be a pointer to an array. So we write `int (*p)[3] = b;` to say, that p is a pointer pointing on a int array with the length of 3.
Edit: And now we can use this like `int x = p[0][1]` or `int y = *(*(p+0)+1)`.
For A[3][2][2],
print A + 1, it should be *A + 16 (size of array [2][2]) but I got + 10.
For example, if *A = 500 -> A + 1 = 516 but I got 510.
Does someone know about this?
For the same input, I am getting it alright, 504 and 520. Have you checked the code again? Also, which compiler and language are you using?
@@allHailKingJulien I run the code on VS Code with Code Runner extension and the language is C++
@@namhuynh6534 I am running it on the same setup, I have no clue where it would have gone wrong
Can anyone in this universe please explain me why the output at 12:53 is not showing 800 please.............reply...........soon.............
i don't know
I have doubt in *(C[0][1]+1) can be represented as &C[0][1][1]= 812 but you write 9, how?
no *(c[0][1] + 1) = c[0][1][1] the value;
Think of it as like this. for each * you are gonna replace a +
so c[0][1][1] = *(c[0][1] + 1) = *(*(c[0]+1) + 1) = *(*(*(c+0)+1)+1). So if you wanna get value in a c[10][20][30] say you want c[9][15][23]
you can do it like
c[9][15][23] = *(c[9][15] + 23) = *(*(c[9]+15)+23) = *(*(*(c+9)+15)+23)
and &c[9][15][23] = (*(*(c+9)+15) + 23) (without first *)
So the ans to your question &c[0][1][1] == (*(*(c+0)+1)+1) without the covering *
this seems simple ......... this is !!! but this is not !!!😒😒
int mtx[2][2] = {0}
int *(p)[2] = mtx;
DOES NOT WORK , WHYYYYYYY??????????????
*should be inside like (*p)[2]. you can use chat gpt for this problems
int (*p)[3] =B
if I try to something like
print (*p)[0] // 2
print (*p)[1] // 3
print (*p)[2] // 6
Now
print (*p)[3] should throw me error but this prints 4 why ?
can I write c[0][5] instead of c[1][1]???
you can
Awesome explanation
6:00