Indians came from another planet, thank you very much for the awesome explanation. Greetings from Italy!
@anabeatriz88353 жыл бұрын
Indians that are educators yes, Indians that are on tiktok no
@dharaniidharkatikaneni49733 жыл бұрын
@@anabeatriz8835 yeah
@satyamrajput8253 жыл бұрын
But in everfield indian always beat other
@Phoenix019143 жыл бұрын
@@satyamrajput825 Each nation has its excellences but remeber, none is better than the others. Your thought remind me some little man living in Germany some years ago..
@satyamrajput8253 жыл бұрын
@@Phoenix01914 yeah ! i agree with your thoughts but it is not a good thing to condemn anyone's
@michaelpatterson10962 жыл бұрын
Had to watch the video 3 times! :) Hopefully I can explain this correctly. At 4:30 in the video, pay attention. If B were a 1d array, then B[0]=200. Then, using * to dereference gives you '2'. If however, B is a 2d array, then once again B[0] = 200 BUT of a 2d array which means when you dereference with *, you are still at 200 but, now in a 1d array! Confused? Watch it over and over like I did. In other words, to print '2' when B is a 2d array, , use **B. This was fouling me up. Got it now. Thank you.
@sudhadevi6692 Жыл бұрын
Didn't understand Help me
@sushmitham1722 Жыл бұрын
this helped to clear my doubt thanks:)
@ibbidevАй бұрын
this makes so much more sense. wow.
@lautarodelucia64807 жыл бұрын
After about 12 straight hours of scratching my head with pointer exercises, all the answers I needed were in this video. Eternally grateful to you!
@jeffflammer96068 жыл бұрын
I have done a lot of online courses included Strang's (MIT) Linear Algebra, Khan Academy, and Noam Nissan's Nand2Tetris. Not sure of the instructors name, but mycondeschool teaches with the same clarity and intuition of these other great instructors.
@anshuman170256 жыл бұрын
Nope, he is from IIIT-Allahabad, not from any IIT. It is only because of his own dedication that he has reached this level of clarity, and not because of his college or anything. Here he is: www.linkedin.com/in/animesh-nayan-0a330812/
@KishanKumar-mz3xr5 жыл бұрын
Thanks for watching. I mean why? . . . THANKS FOR MAKING bruh
@rittenbrake16134 жыл бұрын
yes absolutely
@shubhamshinde56434 жыл бұрын
That what I thought bro
@shubhamshinde56434 жыл бұрын
You steal it
@mrBlagstock4 жыл бұрын
Really enjoy listening to him
@huysaysoui Жыл бұрын
I can’t believe you describe such a complex concepts in this way. Good channel, i will see you a lots
@AbhimanyuAryan10 жыл бұрын
*_i really loved this video. This video was so conceptual i have seen lots of C video playlists on youtube but none of the video covered such details. I really admire the effort you made and you are really good programmer :) hope i get to learn java from you_*
@Boltkiller968 ай бұрын
hey 9 years have passed look at your comment
@Schannel0123 жыл бұрын
It helped me to think about these examples by using the word adress. Also, that part in the begining of the video it is shown that in 1D array B[1] == *(B+1) and &B[1] == B+1. It helped me to think about multi dimensional arrays as things, where the previous two rules apply. Also, keep in mind that if you have a 2D array like in this video B[2][3], if you write B[0] that is a 1D array (1D array which has 3 elements in it). Which means that B[0] is a memory adress. These three insights (or four depending on how you count them) were what made me understand this. Hope this helps to someone struggling to understand this. If you don't get it immediately, watch the video again, think about it and you will understand it.
@shashankkhemka14448 жыл бұрын
This is the best explanation that I have seen so far for this topic. You are really amazing !!
@bukubukuchakama60054 жыл бұрын
This was the best tutorial video on pointers for multi-dimentional array that I have ever watched. Thank you so much for making such tutorial videos,it helps us a lot. Thankyou very much
@mycodeschool11 жыл бұрын
Please watch the video "Pointers and arrays" in this series. It will help you understand the concept.
@chennayaianjc33064 жыл бұрын
Please man come on and do more videos on data structures and interview questions , that make our lives good
@peterpace33794 жыл бұрын
You should really consider coming back to this channel brother. We need you!
@raunakmaheshwari20347 жыл бұрын
To all those who have a doubt that at why 8:29, (B+1) and *(B+1) both are equal to 412, here is the answer. B+1 gives the address of a pointer which is pointing to a 1-D array of size 3. The type of the pointer is such that it points to a 1-D array and in this particular case it is pointing to the 2nd element of the 2-D array, that is, row B[1]. So when you do pointer arithmetic, it will increment or decrement with the size of a 1-D array of size 3. For example, B+2 will give the address of a pointer of the next row in the 2-D matrix, that is, address of B[2]. On the other hand, *(B+1) is a type of an integer pointer which points to the first element of the 1-D array. This is an integer pointer and arithmetic on this would result in increment and decrement with the size of an integer, that is, 4 bytes. Hence *(B+1) +1 would give the address of the next integer!
@mnkshk7 жыл бұрын
thanks
@Aditya-us5gj5 жыл бұрын
Thanks man ! that was helpful
@Mangosrllysuck4 жыл бұрын
So it just so happens that the address of the pointer to second subarray (B+1) is the SAME as the address of the first element of second subarray *(B+1), am I correct?
@Schannel0123 жыл бұрын
@Mangosrllysuck That's what bugs me as well about his comment. Here's how I understood this video. Let's see what *(B+1) + 1 is. *(B+1) is the same as B[1]. So, we get B[1] + 1. We know that B[1] is itself a 1D array. B[1] is therefore the memory adress of that 1D array (elements of the array that I am talking about are B[1][0], B[1][1], B[1][2]). So, B[1] + 1 is the same thing as &(B[1][1]). It is the memory adress of B[1][1]. In other words, it is the number 416.
@Schannel0123 жыл бұрын
@@Mangosrllysuck Did I get it right, is *(B + 1) + 1 equal to 416?
@ulysses_grant7 жыл бұрын
You NAILED it! This is the BEST class of Pointers and 2-D arrasys I've ever seen. FOR GOOD. Thank you so much!!
@jinyunsiwu7 жыл бұрын
good job!!!! you know i can't understand C pointer and some other things about data structures and algorithms ,before watching these videos ! you are the best ! thank you so much ! ---you fans from China
@mycodeschool11 жыл бұрын
&B is address of 2-D array , B is address of first 1-D array in the 2-D array , *B or B[0] is address of first integer in first 1-D array. All of these start at same address. &B[0][0] means address of B[0][0].. once again its the same.. the objects are different in size but their starting address is same. Feel free to ping back if still confused.
@buradaleelaprasanna51315 жыл бұрын
Sir *B means dereferencing then how it could be &B[0][0]
@zezo22abc4 жыл бұрын
how B[0][0] and &B[0][0] the same the 1st give me the value and 2nd give me the address
@tunamusic23144 жыл бұрын
@@buradaleelaprasanna5131 *B or B[0] is address of first integer in first 1-D array. -> it is right ( you can watch previous video about it) &B[0][0] you can split it -> ( & and B[0][0] ) means B[0][0] is the first element of 1-D array so after add " &" , we have adress of the first element of 1-D array
@mycodeschool11 жыл бұрын
Hi Raj , We have a lot of requests for videos on these areas and we definitely want to cover them soon. We currently have only one mentor creating videos and things are slow. We are trying to speed up by pulling in more contribution. Sorry to keep you waiting , but these videos are promised and are high in our priority.
@codewho8193 жыл бұрын
hello :)
@f1ame0n1884 жыл бұрын
omg I love you sir 😂❤ I've been looking for this explaination for literally months and never understood how to handle 2D arrays with pointers untill I saw this video thank you so much for making this video ❤❤
@SuperTurkce7 жыл бұрын
Explained really beautifully! Thanks for allocating your time for creating this series of lectures.
@shivagameon9 жыл бұрын
superb video series , none I have seen that clears concepts in pointers this deep and lucidly.
@wsmao11548 жыл бұрын
it's the best tutorial that i've heard thanks for all effort you made !
@munbee_7 жыл бұрын
Every other videos where great, except this one.. i had to watch it 4-5 times (the part which starts explains 2d array) over to get the pont. anyway, i'm very much thankful that it helped me understand somewhat.
@chennayaianjc33064 жыл бұрын
A best teacher, explains clearly in one single line,
@ianchandra41073 жыл бұрын
Usually hate scouring for coding videos on youtube cause they all suck, but this video really helped! Came into this with a lot of scepticism, but was shocked with how he dumbed everything down to make it understandable (unlike my prof). Thanks for making this video bro, cleared up alot of questions.
@waleedosama16307 жыл бұрын
i can not find someone bettr than you in anything you explain ... you are awesome ...keep up the good work ..thanks
@gianniskurgiakis7394 жыл бұрын
The B[0] = &B[0][0] part in this video is so good that it helped me click something I didn't understand all semester. Thanks for the video!
@Schannel0123 жыл бұрын
Exactly! B[0] is itself an array and when you just put the name of an array, that's the memory adress of the first element of the array. I think I got this, and if I did, then it clicked to me for the same reason that it clicked for you.
@happyteen71952 жыл бұрын
B[0] = &B[0] = &B[0][0] = B = &B = *B all gives same thing i,e same address
@Schannel0122 жыл бұрын
@@happyteen7195 Yes, B[0] gives you the first element of the outer array, which is itself an array, so you get the address of that array. So B=B[0] But then the address of the array B[0] is the address of the first element of the array, which means B = B[0] = &B[0][0]. Then, we also know that *B is the same thing as B[0], so B = B* = B[0] = &B[0][0] Then we know that &B = B because the address of the array = array. &B = B = *B = B[0] = &B[0][0]. I don't know why he didn't write code as an example. I will give you the actual code in the end of the comment. The other way to look at it is this, if we write &B, we get a 3D array whose first element is B, so if we print the that 3D array we will get the address of its first element which is B, and address of B is the address of its first element - B[0], and B[0] is also an array, so the address of B[0] is the address of B[0][0]. Basically, we are talking about the address of B[0][0] all the time. #include int main(){ int B[2][3] = {{0,1,2}, {3,4,5}}; printf(" B = %lld ", B); printf(" &B[0] = %lld ", &B[0]); printf(" B[0] = %lld ", B[0]); printf(" &B = %lld ", &B); printf(" "); int A[4] = {1, 2, 3, 4}; printf("A = %lld ", A); printf("&A = %lld ", &A); return 0; }
@Schannel0122 жыл бұрын
@@happyteen7195 Here is a video which explains this with code kzbin.info/www/bejne/nJLPfHWHi7yGgtk
@Schannel0122 жыл бұрын
@@happyteen7195 Another important thing to say, and I am saying this while hoping that this will not just confuse you more, is that if you write int (*b)[3] = B; computer will treat b and B differently. In what sense? In a sense that if you write &b, computer will treat that as a double pointer, as an address of b. It will treat b as int** [3]. On the other hand, if you write &B, computer will treat &B as a pointer to a 3D array whose first element is B. Computer will treat &B as int* [2][3]. In other words B is equal to &B, but &b is not equal to b. Here is a program for you to check out on your own, I wanted these warning signs intentionally btw so that compiler tells us what types B, &B, b, &b etc. are #include int main(){ int B[2][3] = {{0,1,2}, {3,4,5}}; printf(" B = %lld ", B); printf(" &B[0] = %lld ", &B[0]); printf(" B[0] = %lld ", B[0]); printf(" &B = %lld ", &B); printf(" "); int A[4] = {1, 2, 3, 4}; printf("A = %lld ", A); printf("&A = %lld ", &A); printf(" "); int* a = A; printf("a = %lld ", a); printf("&a = %lld ", &a); printf(" "); int (*b)[3] = B; printf("b = %lld ", b); printf("&b = %lld ", &b); return 0; }
@ShopperPlug2 жыл бұрын
Holy cow, this is another realm of C programming and can write pointer codes my ways. I would never be able to figure out how all of the advanced pointer code works without understanding the fundamentals.
@jonvonnoobman28232 жыл бұрын
Dude, u rock! U explain stuff much better than IIT profs. And yeah, this is coming from an IIT fresher.
@ryankhullar6289 Жыл бұрын
kaunsi IIT Hai?
@mirageleung4 жыл бұрын
First off, thank you so much for these videos. They are phenomenal. I'm at 6:10 and am a bit confused about *B as it's not declared as a pointer. How is *B = B[0] = &B[0][0], I would guess that *B was dereferencing, but then wouldn't get the value instead?
@samdavepollard4 жыл бұрын
B is the name of our 2d array. That name acts as a pointer to the first element in the array. But the first element in the array is not an int - it's a 1d array of ints, called B[0] Hence, B = &B[0] Dereferencing gives us *B = B[0] Now, B[0] is a 1d array of ints. We know that the name of an array can be used as a pointer to the first element in that array. So the name B[0] points to the first element in that array of ints In other words, B[0] = &B[0][0] Hope that helps. PS. Also worth noting that since *B = B[0] = &B[0][0] if we dereference everything we get **BB = * B[0] = B[0][0] In other words, dereferencing the name of a 2-d array twice gives us the first element in the first row.
@418_akshitasharma33 жыл бұрын
@@samdavepollard thank you!!!!! I was so fucking confused!!!
@smrtfasizmu61613 жыл бұрын
*B gets you B[0], however B[0] is itself an array and array, so B[0] is a memory address of the array whose elements are B[0][1][2]
@shadabahmed45474 жыл бұрын
sir really you have very deep knowlege.My concepts are cleared so much ,now i have to just apply it in real code
@jupiterscreams8 жыл бұрын
Thank you for this tutorial. Very easy to understand!
@225mrraj11 жыл бұрын
u r simply the BEST on youtube.!!
@minatorman50475 жыл бұрын
b+1 gives 412 !! *(b+1) should gives the value stored in that particuler address why it gives an addresss ??
@abdimalikosman5594 жыл бұрын
That is what i was thinking too.
@charansashidhar22144 жыл бұрын
@Vaneet Gupta what is *B
@balaganesh34404 жыл бұрын
@@charansashidhar2214 *B returns the initial address of the first element in the first row of the multi dim array. In this case, B and *B are the same, since both represent the address of the initial element of the whole multi dim array which is nothing but the first element in the first row. When we dig into the multi dim array, say, B[0] returns the address of the first element of the initial row, *B[0] returns the value at the first element of the initial row. B[1] returns the address of the first element of the second row, *B[1] returns the value at the first element of the second row. When we still dig deeper we get the values, say, B[0][0] returns the value of the first element in the first row. Don't get confused about the following, internally the array works in the way when we get B[1][1] , *(*B[1] + 1) //this is the structure of the element B[1][1] => *(&B[1][1]) // returns the address of B[1][1] which is then dereferenced to get the value. => B[1][1] // C provides an easy way to access the elements directly from this step by ignoring the above steps => value at B[1][1]
@saimanognanelavelli80053 жыл бұрын
This is actually explained in some previous video , when they talk about generic pointer and why the pointers have types like int *p1;char *p2 ...... Because we can dereference them later and for that we need to know what exactly lies at address 412, is it an int ? (no) there is an array B[1] stored at 412 . Now 412 is actually address of an array B[1] (let B[1]=A) so the statement printf( *(B+1) )=printf( B[1] )=Printf(A) which gives base address/address of first value ( A[0] or B[1][0]) hope it helps :)
@sans.creates3 жыл бұрын
@@saimanognanelavelli8005 do u wanna say B+1 AND *(B+1) are the same?
@amizan86538 жыл бұрын
This video was infinitely helpful, thanks for posting!
@travellingsLenses6 жыл бұрын
One of the best stuff available on the internet. :) Keep it up.
@1qaribullah7 жыл бұрын
Great explanation... No need to study books. Thumb up..!!!!!!!!
@mycodeschool11 жыл бұрын
Thanks Adamou :)
@Xardas_2 жыл бұрын
Pointers are no longer over my head. Thanks a lot !
@johnparks69368 жыл бұрын
Does anyone here understand why (b+1) and *(b+1) both produce 412? If you dereference shouldn't it produce the contents of 412 which is 4?
@Abhi94manyu8 жыл бұрын
Exactly my doubt
@johnparks69368 жыл бұрын
Abhimanyu Bhardwaj Yea, I still can't understand. Hopefully someone will help us.
@shishupal0iitb878 жыл бұрын
did u get the answer to your doubt? i think its because : Thinking that 2-D array is an array of arrays,* (B+1) or B[1] should get you to second array (Second Row) which is an array instead of int element. And when array is assigned to something its the address of first element that gets assigned. So de-referencing it only once gets you the starting address of second array. De-referencing it again should get you the 4 ie **(B+1)=4. hope that makes sense
@pandalover5558 жыл бұрын
That makes so much sense - thank you!
@_kahini7 жыл бұрын
+Shishupal is **(B+1) and *(*B+1) the same or u made a mistake ?
@dzzzzzt9 жыл бұрын
A very eloquent way to present the topic. Hopefully many people will benefit from this. I certainly did for which I'm thankful. I'd appreciate if there was also an explanation as to why a pointer to an array of pointers has to be declared as int (*p)[3] although it may be a more advanced topic. Why can't int **p work? It is seen on the picture but not explained in full detail, i.e. the multidimensional array is located continuously in memory. So because of that in pointer arithmetic advancing the pointer with 1 must not move it by one byte (as if it were int **p) but by three (because of int (*p)[3]). int (*p)[3] literally means "a pointer to an array of three integers". int p[3] means that p is an array of 3 integers. Adding the asterisk makes p a pointer to an array of 3 integers, which is equivalent to the definition that the name of the array is a pointer to its first element.
@baltatuandrei38368 жыл бұрын
+simich you have to know how to handle an expression .This links will help you c-faq.com/decl/spiral.anderson.html . This way you can see how the compiler looks and interprets an expression. (*p)[3] it states that p is a pointer to an array with 3 elements. It is because of array decaying. Whenever you assign a x-dimensional static declared array to a pointer,one dimension is lost(in the example (*p)[3]=B is really like (*p)[3]=&B[0],and &B[0] is an address to an array of 3 elements). You could ask,of,so I could do *p =&B[0] cuz I know I can do p=a where a is 1d array. But the compiler won't let you do this. At compile time it that B[0] has 3 elements ,and wants you to pass a pointer to 3 elements. What I'm saying about array decay,you see that (*p)[3] know there are 3 elements on a row,but doesn't know how many rows there are. You should really read a lot of topics on these ,it's not easy and it's tricky. All I say is this. Arrays are not pointers and pointers are not arrays.Even if you can do *pointer and *array,and you can pass an array to a pointer,deep down they aren't the same.At compile time you know the sizeof static declared array,but you can't know the size of what the pointer points to just until run-time,so it has some loss when passing as parameter.
@Shaddad_Gomid5 жыл бұрын
Thanks a lot, the most informative and to-the-point video about this subject
@ahmeddeiaa39437 жыл бұрын
this tutorial is quite amazing. Thank you and please keep it up
@CylinderHead19 жыл бұрын
What he says is totally right , it is in fact a little different than a 1D array. Just try it in your compiler and you'll see !
@multitech17196 жыл бұрын
int *pB=B; for a 2 by 3 array and int (*pB)[3]=B; both compiled perfectly returning same output without any error using Codeblocks.
@shikharchandra30289 жыл бұрын
@mycodeschool shouldn't * print the value instead of address? Please clarify
@_kahini7 жыл бұрын
in 2D array to get the value of that particular address you have to write *(*c+i) for example coz * is just a pointer to an integer
@adstub7 жыл бұрын
See try to see it this way there is an array inside an array so the first time it is only going to give the address of the array and then we are going for the address of the variable name of the one dimensional array.
@Schannel0123 жыл бұрын
But the value of B[0] is an array, and arrays are represented as a memory adress of their first element.
@rishabh60514 жыл бұрын
thanks for making this video, I was very struggling with pointer to array. You have explained very well
@jeromyclassyca70633 жыл бұрын
This is the only lesson I found difficult that this man taught
@siishasha21765 жыл бұрын
You are an Angel! Thank you so much for all these amazing videos!
@deepeshshrestha10363 жыл бұрын
This is cool 🌊 . I still haven't grasped the concept the way 2D array name makes partition to the memory but if that foundation is pre-set by law(law of C language 😝) Then you have my gratitude brother. I got this.❤️
@yashpandey95508 жыл бұрын
At 8:27 , you were trying to explain B+1 and *(B+1)....Its a bit confusing ! How B+1 and *(B+1) giving the same result , i.e. 412 ???? Please explain :D Thanks !
@sandrok148 жыл бұрын
+Yash Pandey That is an error I suppose. It should give us value 4
@btcblade33348 жыл бұрын
bro your videos are so good and concise
@MrViney3339 жыл бұрын
@mycodeschool Thanks to you pointers is clear to me. Thank you very much
@priyasukumaran5 жыл бұрын
Sir.. you doing a great job.. thank you so much..!!
@amritmalla5 жыл бұрын
For n dimensional array by dereferencing it by n asterisk, it will completely dereference the pointer to give the value for e.g. b[2][2][2], ***b = value in the b[0][0][0], so ***b + 1, here 1 is added to the value of array **b + 1, means that pointer to int array ( 4 byte is added ) *b +1, means that pointer to 1d array of size 2( 8 byte is added) b + 1, means that pointer to 2d array of size 2X2 ( 16 byte is added)
@theadel85913 жыл бұрын
excellent explanation, not a strightforward concept (pointers of 2-D arrays) but manageable with some practice !
@14JINU1410 жыл бұрын
Excellent walk-through. Well explained with very good examples. Thank you so much.
@user-or7ji5hv8y6 жыл бұрын
you are really a great teacher! such lucid explanation.
@greymind00723 жыл бұрын
How come deferencing a pointer still giving as the address and instead of value at that address-> timestamp[ 8:28 ] => here *( B+1) = B[1] how this can equal to &B[1][0] = 412 ?......isn't deferencing of pointer var should give us the value and not the address ???
@roshaniguthe79837 жыл бұрын
very good lecture....specially memory allocation topic is very nicely explain
@shahirabdullah54389 жыл бұрын
sorry i wanted to tell about 6:23 not 5:59, there he used asterisk in B to print the adress not value of B ? and he said *B = B[0] = &B[0][0] in 6:16 , i can understand for 1D *B = B[0], but 2d seems totally confusing to me for this *B = B[0] = &B[0][0] :(
@deepakdev80389 жыл бұрын
B[0] is the name of the 1st array.So,name of an array would giv u the address of first element of that array so,B[0]==&B[0][0]
@garryharry10249 жыл бұрын
+Deepak Devarakonda OHH... That makes complete sense! Thanks Deepak for this clarification. I had the same question as Shahir...
@ChekuriKavitha11 ай бұрын
A very good explanation on pointers. Plz give answer for *(B+1)[0]
@cokpot63511 жыл бұрын
Why is it in 8.29, the *(B+1) or B[1] or &B[1][0] is equal to 412 ? I thought it would be 4.
@gautam933951313110 жыл бұрын
Hi do knw the ans now ???
@mayukh_10 жыл бұрын
No to get 4, you have to write **(B + 1) or 0[1[B]]
@garryharry10249 жыл бұрын
+Nafiz Farhan Hey Nafiz. Let's break down *(B+1). First let's take a look at B. B is a 1-D array of three integers. In other words, B is simply the name of that 1-D array consisting of three integers. So therefore, it would give you a pointer to this 1-D array of three integers. Now if you increment B (since the type of B is a pointer to an array of three integers) it will increment B by 12 (since 3*4 = 12 bytes). Now B is pointing to the second array of three integers. Which is the same as B[1]. Now (B+1) combined gives you the pointer to the second array of three integers. Now if you dereference that it would give you the address of the first integer in that second 1-D array which is 412.
@probhakarsarkar24307 жыл бұрын
wrong
@probhakarsarkar24307 жыл бұрын
I think like that: B[i] is a pointer to the pointer &B[i][j] i.e. B[0] is the pointer to the pointer &B[0][0].
@moony19264 жыл бұрын
Super super helpful and clear! Thank you so much!
@AishLovesSpaghetti3 жыл бұрын
But in the previous videos you said that arithmetic operations on array will result in error but such incrementation operations can be performed on pointers. But here B is the name of the array.
@03Karthikeyan9 жыл бұрын
Thanks man! I had to listen to this couple of times, but it made sense.
@SmartProgramming6 жыл бұрын
very helpful video sir, the way you have explained is really appreciating, thank you 👍👍
@amanpahwa2113 жыл бұрын
9:22 reference with green colour. NICE
@jamejustice009 жыл бұрын
does anybody find that what he said in 5:50 is incorrect? I created a 2d array and a pointer and still can assign the array to the pointer as I expected; p = array. As far as I concern, array hold the address of the its first element, which in turn holds its first element. As a result, the outer array actually hold the address of the first element of its first element, saying a character in my example. He said c compiler would cause error because B hold address of a multi array. But again, the address of the array is the address of its first element. So, I don't see the difference between assign an 1d array to a pointer and a multi-d array to a pointer. And this really make the difference between array and pointer more confused to me. Any one can point out the difference?
@TheSeeker144919 жыл бұрын
The GCC v4.8.3 compiler indeed lets me compile, but gives the warning "initialization from incompatible pointer type". You are right in that if 'b' is a 2d array and you use 'int *p = b', 'p' will have the same value as if you did 'int (*p)[3] = b'. The problem comes when you dereference 'p'. You will get an error when you use '**p' or 'p[1][0]' for example. If you use 'int *p = b' you are not telling the C compiler that the ints at address 'b' come in sets of 3, and it needs this information to do the required pointer arithmetic.
@kautukraj5 жыл бұрын
Very helpful.
@apoorvsharma35039 жыл бұрын
hey but i think that * is used to print the value at the addres ....but in video u r print the address while using * .....{asking u toclear my confusion}
@idontevenknow37076 жыл бұрын
this is because its a 2D array, so there is an added layer. One *, will give you one of the two arrays, whereas two * will reach the value at the given address.
@BBaDDaYY6 жыл бұрын
I think he sorted it out himself throughout those years :D
@kaizhang67686 жыл бұрын
in a harder way XD
@anondoggo5 жыл бұрын
@@idontevenknow3707 Thanks for the clarification. This confused me a lot as well.
@AffaAu4 жыл бұрын
Great effort, great explanation. Thanks.
@sahilkanojia25317 жыл бұрын
sir, I will understand good from your excellent explaination thank you so much
@THEtruth84748 жыл бұрын
at 5:43 i dont get it i can also define a 1d array of 3 integers like int *p , p = (int *)malloc(sizeof(int)) . declaration of a variable pointer and array pointer are the same . so int *p = b[0] should return a pointer pointing to 1d array of 3 integers which is p which is pointing to b[0][0] . can some one explain me this ??????
@shiwangiagrawal85496 жыл бұрын
Very good video. Thanku soo much. Helped a lot.😊😊
@Rakeshrajeev945 жыл бұрын
Very much helpful. Thanks team 😊
@09charger18 жыл бұрын
@8:25, I don't understand how B+1 and *(B+1) give you the same answer???
@kimron927 жыл бұрын
B+1 is a pointer to a one dimensional array of length 3 in this case.. If you do (B+1)+1 you will get 424.. *(B+1) is a pointer to first element of an array of length 3. If you do *(B+1)+1 you will get 416.. Here you can see that B+1 and *(B+1), although are different from each other in how they behave, here they are pointing to the same thing i.e the address of the location where 412 is stored.. Since the address is same we get the same value for both of these pointers.
@patrasculucian24036 жыл бұрын
B+1 = address at B[1] *(B+1) = *B[1] = address at B[1][0] address at B[1] = address at B[1][0] But this is not quite the same thing. They got the same adress but there is a difference between them. Let's suppose: B[0] has adress 400 B[0][0] has adress 400 also. The difference comes with math opperations: B[0] + 1 = B[1] (address 412) B[0][0] + 1 = B[0][1] (address 404)
@afeezramoni47816 жыл бұрын
I was in doubt but I trust this guy's stuff. So I ran these few lines to validate....mehn, he was right as usual int main() { int B[2][3]; int* point2D = B; printf("The address of &B[0] is %p ", &B[0] ); printf("The address of *B is %p ", *B); printf("The address of B+1 is %p ", B+1 ); printf("The address of &B[1] is %p ", &B[1] ); printf("The address of *(B+1) is %p ", *(B+1) ); printf("The address of B[1] is %p ", B[1]); printf("The address of &B[1][0] is %p ", &B[1][0] ); } See results: The address of &B[0] is 0x7ffee9c11a60 The address of *B is 0x7ffee9c11a60 The address of B+1 is 0x7ffee9c11a6c The address of &B[1] is 0x7ffee9c11a6c The address of *(B+1) is 0x7ffee9c11a6c The address of B[1] is 0x7ffee9c11a6c The address of &B[1][0] is 0x7ffee9c11a6c
@vasudhadixit5386 жыл бұрын
Afeez Ramoni How can be your address value contain characters ?
@zezo22abc4 жыл бұрын
@@vasudhadixit538 because this is a hexadecimal base and a means 10 c means 12 to f means 15 and so on
@krishnamurthynaik54974 жыл бұрын
At 11:23 b is the address of 1st element that is 400 and *b is 2 and *b+1 is 3 and *(*b+1) is the address of 3 that is 404 not 3
@dharmikmistry87814 жыл бұрын
Thanks for your great efforts 🔥🔥😍🤗
@nuradilzholmukhan86726 ай бұрын
holy shit what a golden video! THANKS
@katheringomez85124 жыл бұрын
The precedence of the signs does not affect the operation that is doing *(b + 1) + 2. According to my concepts, by the way you are locating the data, it goes to the second element of the array, then desreference and adds 2 to the value. Therefore I think it would be necessary to use the parentheses *((b + 1) + 2). Could you please correct me, thank you very much for taking the time to explain.
@jingfanwong47558 жыл бұрын
i am not sure if i understood it, assume we have a 2d array and a pointer to it like this: int feld[3][5]; int* pointer[5]; pointer = feld; ok, now lets say i would like to enter the value in the array cell feld[2][4].........would i have to write: *(*(pointer+2)+4) ???
@sayantaniguha85194 жыл бұрын
3:48 You meant instead of writing 1st line as **p = A* , We can also write it as *p=A* ?
@adelleshob3660 Жыл бұрын
Thank you so much you solved my problem !!
@farezuanruzlan2929 жыл бұрын
+mycodeschool is it the same case for 2d array of strings?
@TheMateyl6 жыл бұрын
great explanation
@2311kamal2 жыл бұрын
the best video ever!!
@MrAltQQer8 жыл бұрын
You're a Monster.
@thebishalpaul5 жыл бұрын
how an integer can be of 4 byte as integers at most in of 2 byte?
@zezo22abc4 жыл бұрын
it depends on the compiler if you use a 32-bit system then integer will be 4 bytes >>> 2 bytes means that you use a processor of 16-bit also if the processor is 64-bit then int will reserve 8 bytes neither 2 nor 4 , hit : if you want to check the volume of your int you can use this statment printf("%d",sizeof(int)); also you can replace int with any data type like char, double and so on .
@snv19965 жыл бұрын
An excellent video mate! I dont know what your profession is But you should definitely teach in universities!! Thanks a lot from behalf of all the programmers you helped! (including me)
@mdmurtaza83212 жыл бұрын
He is software engineer at google
@shahirabdullah54389 жыл бұрын
can anybody plz help me out? B in 5:59 the or &B[0] is showing 400. why? should'nt it print the value on B?
@shahirabdullah54389 жыл бұрын
thanks
@notepad8008 жыл бұрын
If i take the expression *(*p + k) and loop it from k = 0 to k = i*j - 1, I am scanning the entire 2-D array. So isnt this a better way to access 2-D arrays as it takes O(n) time compared to the other way which takes O(n^2)??
@pveldhose62117 жыл бұрын
sir write a program to find the sum of both diagonals separately of 2D array
@gokuafrica9 жыл бұрын
finally got it. Thank you!!!!!!
@karimshaikh39003 жыл бұрын
Very well explained!
@sagarsaha37626 жыл бұрын
Hey, the website at mycodeshool.com doesn't' work at all. It says "502 Bad Gateway". Please fix this immediately.
@PetBuddies3 жыл бұрын
So good explanation __
@pavanbhalkey43098 жыл бұрын
can any explain the point at 8:50 plzz how can *(B+1)+2 =420?? im getting 6 since i) B+1 = 412 ii) *(B+1)=4 iii)*(B+1)+2=4+2=6
@SaurabhSingh3078 жыл бұрын
*(B+1) points to the second row i.e. B[1] . So *(B+1) =address of B[1]=412. Now *(B+1)+2 "navigates" to two elements forward the base i.e. points to B[1][2]. So, *(B+1)+2 = address of B[1][2]= 420. Alternatively, it can be seen that since we have to move forward 2 elements in *(B+1) i.e. B[1]. So, *(B+1)+2 will now point to address that is 2 integer element farther to the base address of B[1] => 412 +2*memory taken by 1 integer( since the pointer is of int type) element = 412 + 2*4= 420
@pedroantoniodesouzasilva20685 жыл бұрын
Thank you very much, my friend!
@vivekd42785 жыл бұрын
Nice explanation!
@Utshaw6 жыл бұрын
5:56 Here, he wrote , int (*p)[3] = B; I couldn't understand the (*p)[3] part. Can anyone explain me ??
@songforged5 жыл бұрын
Brackets generally mean that you have to read/perform what's inside them first. So the fact that *p is in brackets mean that "p is a pointer..." and the [3] outside it then means that "... that points to an array of size 3."
@xMrJanuaryx10 жыл бұрын
The following code prints Robert. Why is that so if c is simply a pointer to the first element in the array? Shouldn't it be printing an address to the first element in the array? int main() { char c[] = "Robert"; printf("%s", c); return 0; }
@talhaanwar21788 жыл бұрын
+Robert Murch int main() { char c[] = "Robert"; printf("%p", c); return 0; } Just replace %s with %p.
@nafisfaiyaz75436 жыл бұрын
when you write %s, the compiler starts looking for null character. so, writing %s will give you the whole array.