Pointers and 2-D arrays

Поделиться
HTML-код
  • Опубликовано: 23 окт 2024

Комментарии • 308

  • @Phoenix01914
    @Phoenix01914 3 года назад +135

    Indians came from another planet, thank you very much for the awesome explanation. Greetings from Italy!

    • @anabeatriz8835
      @anabeatriz8835 3 года назад +41

      Indians that are educators yes, Indians that are on tiktok no

    • @dharaniidharkatikaneni4973
      @dharaniidharkatikaneni4973 3 года назад +3

      @@anabeatriz8835 yeah

    • @satyamrajput825
      @satyamrajput825 3 года назад +2

      But in everfield indian always beat other

    • @Phoenix01914
      @Phoenix01914 3 года назад +10

      @@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..

    • @satyamrajput825
      @satyamrajput825 3 года назад +1

      @@Phoenix01914 yeah ! i agree with your thoughts but it is not a good thing to condemn anyone's

  • @jeffflammer9606
    @jeffflammer9606 8 лет назад +55

    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.

    • @anshuman17025
      @anshuman17025 6 лет назад +16

      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/

  • @AbhimanyuAryan
    @AbhimanyuAryan 10 лет назад +116

    *_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_*

    • @Boltkiller96
      @Boltkiller96 6 месяцев назад

      hey 9 years have passed look at your comment

  • @KishanKumar-mz3xr
    @KishanKumar-mz3xr 5 лет назад +183

    Thanks for watching. I mean why?
    .
    .
    .
    THANKS FOR MAKING bruh

  • @lautarodelucia6480
    @lautarodelucia6480 7 лет назад +8

    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!

  • @michaelpatterson1096
    @michaelpatterson1096 Год назад +14

    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
      @sudhadevi6692 Год назад +1

      Didn't understand
      Help me

    • @sushmitham1722
      @sushmitham1722 Год назад

      this helped to clear my doubt thanks:)

    • @ibbidev
      @ibbidev 4 дня назад

      this makes so much more sense. wow.

  • @midrangeshot8203
    @midrangeshot8203 2 года назад +5

    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.

  • @bukubukuchakama6005
    @bukubukuchakama6005 4 года назад +4

    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

  • @jinyunsiwu
    @jinyunsiwu 7 лет назад +8

    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

  • @huysaysoui
    @huysaysoui Год назад +2

    I can’t believe you describe such a complex concepts in this way. Good channel, i will see you a lots

  • @shashankkhemka1444
    @shashankkhemka1444 8 лет назад +6

    This is the best explanation that I have seen so far for this topic. You are really amazing !!

  • @ulysses_grant
    @ulysses_grant 6 лет назад +2

    You NAILED it! This is the BEST class of Pointers and 2-D arrasys I've ever seen. FOR GOOD. Thank you so much!!

  • @f1ame0n188
    @f1ame0n188 4 года назад +4

    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 ❤❤

  • @SuperTurkce
    @SuperTurkce 7 лет назад +5

    Explained really beautifully! Thanks for allocating your time for creating this series of lectures.

  • @raunakmaheshwari2034
    @raunakmaheshwari2034 7 лет назад +27

    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!

    • @mnkshk
      @mnkshk 7 лет назад

      thanks

    • @Aditya-us5gj
      @Aditya-us5gj 5 лет назад

      Thanks man ! that was helpful

    • @Mangosrllysuck
      @Mangosrllysuck 4 года назад +1

      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?

    • @midrangeshot8203
      @midrangeshot8203 2 года назад

      @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.

    • @midrangeshot8203
      @midrangeshot8203 2 года назад

      @@Mangosrllysuck Did I get it right, is *(B + 1) + 1 equal to 416?

  • @ianchandra4107
    @ianchandra4107 3 года назад

    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.

  • @dzzzzzt
    @dzzzzzt 9 лет назад +3

    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.

    • @baltatuandrei3836
      @baltatuandrei3836 8 лет назад +2

      +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.

  • @wsmao1154
    @wsmao1154 8 лет назад +2

    it's the best tutorial that i've heard
    thanks for all effort you made !

  • @chennayaianjc3306
    @chennayaianjc3306 3 года назад

    A best teacher, explains clearly in one single line,

  • @waleedosama1630
    @waleedosama1630 7 лет назад

    i can not find someone bettr than you in anything you explain ... you are awesome ...keep up the good work ..thanks

  • @mycodeschool
    @mycodeschool  11 лет назад +17

    Please watch the video "Pointers and arrays" in this series. It will help you understand the concept.

    • @chennayaianjc3306
      @chennayaianjc3306 3 года назад +1

      Please man come on and do more videos on data structures and interview questions , that make our lives good

    • @peterpace3379
      @peterpace3379 3 года назад +1

      You should really consider coming back to this channel brother. We need you!

  • @jupiterscreams
    @jupiterscreams 8 лет назад +2

    Thank you for this tutorial. Very easy to understand!

  • @munbee_
    @munbee_ 7 лет назад +1

    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.

  • @shivagameon
    @shivagameon 9 лет назад

    superb video series , none I have seen that clears concepts in pointers this deep and lucidly.

  • @amizan8653
    @amizan8653 8 лет назад +3

    This video was infinitely helpful, thanks for posting!

  • @shadabahmed4547
    @shadabahmed4547 4 года назад +1

    sir really you have very deep knowlege.My concepts are cleared so much ,now i have to just apply it in real code

  • @shikharchandra3028
    @shikharchandra3028 9 лет назад +26

    @mycodeschool shouldn't * print the value instead of address? Please clarify

    • @_kahini
      @_kahini 7 лет назад +8

      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

    • @adstub
      @adstub 7 лет назад +19

      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.

    • @midrangeshot8203
      @midrangeshot8203 2 года назад

      But the value of B[0] is an array, and arrays are represented as a memory adress of their first element.

  • @multitech1719
    @multitech1719 6 лет назад +1

    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.

  • @gianniskurgiakis739
    @gianniskurgiakis739 4 года назад +2

    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!

    • @midrangeshot8203
      @midrangeshot8203 2 года назад +2

      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.

    • @happyteen7195
      @happyteen7195 2 года назад +1

      B[0] = &B[0] = &B[0][0] = B = &B = *B all gives same thing i,e same address

    • @midrangeshot8203
      @midrangeshot8203 2 года назад

      ​@@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;
      }

    • @midrangeshot8203
      @midrangeshot8203 2 года назад

      @@happyteen7195 Here is a video which explains this with code ruclips.net/video/falKBQVWSLw/видео.html

    • @midrangeshot8203
      @midrangeshot8203 2 года назад

      @@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;
      }

  • @mycodeschool
    @mycodeschool  11 лет назад +2

    &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.

    • @buradaleelaprasanna5131
      @buradaleelaprasanna5131 5 лет назад

      Sir *B means dereferencing then how it could be &B[0][0]

    • @zezo22abc
      @zezo22abc 4 года назад +1

      how B[0][0] and &B[0][0] the same the 1st give me the value and 2nd give me the address

    • @tunamusic2314
      @tunamusic2314 4 года назад

      @@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

  • @ChekuriKavitha
    @ChekuriKavitha 9 месяцев назад

    A very good explanation on pointers. Plz give answer for *(B+1)[0]

  • @mycodeschool
    @mycodeschool  11 лет назад +5

    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.

  • @SmartProgramming
    @SmartProgramming 6 лет назад

    very helpful video sir, the way you have explained is really appreciating, thank you 👍👍

  • @amritmalla
    @amritmalla 5 лет назад

    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)

  • @Shaddad_Gomid
    @Shaddad_Gomid 5 лет назад +2

    Thanks a lot, the most informative and to-the-point video about this subject

  • @mycodeschool
    @mycodeschool  11 лет назад +13

    Thanks Adamou :)

  • @ahmeddeiaa3943
    @ahmeddeiaa3943 7 лет назад +2

    this tutorial is quite amazing. Thank you and please keep it up

  • @minatorman5047
    @minatorman5047 4 года назад +35

    b+1 gives 412 !! *(b+1) should gives the value stored in that particuler address why it gives an addresss ??

    • @abdimalikosman559
      @abdimalikosman559 4 года назад +5

      That is what i was thinking too.

    • @vaneetgupta7189
      @vaneetgupta7189 4 года назад +11

      print *(b+1) is same as
      print b[1] where b[1][3]={4,5,6}
      think of it as
      Print A where A[3]={4,5,6}
      this will print the address of the first element of A[3].

    • @charansashidhar2214
      @charansashidhar2214 4 года назад

      @@vaneetgupta7189 what is *B

    • @balaganesh3440
      @balaganesh3440 4 года назад +11

      @@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]

    • @saimanognanelavelli8005
      @saimanognanelavelli8005 3 года назад +4

      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 :)

  • @kautukraj
    @kautukraj 5 лет назад +2

    Very helpful.

  • @rishabh6051
    @rishabh6051 4 года назад

    thanks for making this video, I was very struggling with pointer to array. You have explained very well

  • @mirageleung
    @mirageleung 4 года назад +2

    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?

    • @samdavepollard
      @samdavepollard 4 года назад +9

      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_akshitasharma3
      @418_akshitasharma3 2 года назад +2

      @@samdavepollard thank you!!!!! I was so fucking confused!!!

    • @smrtfasizmu6161
      @smrtfasizmu6161 2 года назад

      *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]

  • @johnparks6936
    @johnparks6936 8 лет назад +24

    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?

    • @Abhi94manyu
      @Abhi94manyu 8 лет назад

      Exactly my doubt

    • @johnparks6936
      @johnparks6936 8 лет назад +1

      Abhimanyu Bhardwaj Yea, I still can't understand. Hopefully someone will help us.

    • @shishupal0iitb87
      @shishupal0iitb87 8 лет назад +43

      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

    • @pandalover555
      @pandalover555 8 лет назад +1

      That makes so much sense - thank you!

    • @_kahini
      @_kahini 7 лет назад

      +Shishupal is **(B+1) and *(*B+1) the same or u made a mistake ?

  • @14JINU14
    @14JINU14 10 лет назад

    Excellent walk-through. Well explained with very good examples. Thank you so much.

  • @theadel8591
    @theadel8591 2 года назад

    excellent explanation, not a strightforward concept (pointers of 2-D arrays) but manageable with some practice !

  • @deepeshshrestha1036
    @deepeshshrestha1036 3 года назад +1

    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.❤️

  • @priyasukumaran
    @priyasukumaran 4 года назад +1

    Sir.. you doing a great job.. thank you so much..!!

  • @jonvonnoobman2823
    @jonvonnoobman2823 2 года назад +1

    Dude, u rock! U explain stuff much better than IIT profs. And yeah, this is coming from an IIT fresher.

  • @MrViney333
    @MrViney333 9 лет назад

    @mycodeschool Thanks to you pointers is clear to me. Thank you very much

  • @1qaribullah
    @1qaribullah 7 лет назад +1

    Great explanation... No need to study books. Thumb up..!!!!!!!!

  • @btcblade3334
    @btcblade3334 7 лет назад

    bro your videos are so good and concise

  • @Xardas_
    @Xardas_ 2 года назад

    Pointers are no longer over my head. Thanks a lot !

  • @music-mw3qt
    @music-mw3qt 3 года назад

    Great exploration

  • @ShopperPlug
    @ShopperPlug 2 года назад

    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.

  • @TheMateyl
    @TheMateyl 6 лет назад +2

    great explanation

  • @225mrraj
    @225mrraj 11 лет назад +1

    u r simply the BEST on youtube.!!

  • @yashpandey9550
    @yashpandey9550 8 лет назад +6

    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 !

    • @sandrok14
      @sandrok14 8 лет назад +3

      +Yash Pandey That is an error I suppose. It should give us value 4

  • @user-or7ji5hv8y
    @user-or7ji5hv8y 5 лет назад

    you are really a great teacher! such lucid explanation.

  • @kamayosh1
    @kamayosh1 Год назад

    thank for your helpful lesson

  • @siishasha2176
    @siishasha2176 4 года назад

    You are an Angel! Thank you so much for all these amazing videos!

  • @roshaniguthe7983
    @roshaniguthe7983 7 лет назад

    very good lecture....specially memory allocation topic is very nicely explain

  • @adelleshob3660
    @adelleshob3660 Год назад

    Thank you so much you solved my problem !!

  • @AishLovesSpaghetti
    @AishLovesSpaghetti 3 года назад +1

    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.

  • @CylinderHead1
    @CylinderHead1 9 лет назад +1

    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 !

  • @katheringomez8512
    @katheringomez8512 4 года назад

    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.

  • @music-mw3qt
    @music-mw3qt 3 года назад

    You have explained well

  • @AffaAu
    @AffaAu 4 года назад

    Great effort, great explanation. Thanks.

  • @travellingsLenses
    @travellingsLenses 6 лет назад +1

    One of the best stuff available on the internet. :) Keep it up.

  • @mahipalsingh-yo4jt
    @mahipalsingh-yo4jt 4 года назад

    great explanation..........!

  • @vivekd4278
    @vivekd4278 5 лет назад

    Nice explanation!

  • @cokpot635
    @cokpot635 10 лет назад +20

    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.

    • @gautam9339513131
      @gautam9339513131 9 лет назад

      Hi do knw the ans now ???

    • @mayukh_
      @mayukh_ 9 лет назад +2

      No to get 4, you have to write **(B + 1) or 0[1[B]]

    • @garryharry1024
      @garryharry1024 9 лет назад +7

      +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.

    • @probhakarsarkar2430
      @probhakarsarkar2430 7 лет назад

      wrong

    • @probhakarsarkar2430
      @probhakarsarkar2430 7 лет назад

      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].

  • @farezuanruzlan292
    @farezuanruzlan292 9 лет назад +1

    +mycodeschool is it the same case for 2d array of strings?

  • @jingfanwong4755
    @jingfanwong4755 8 лет назад +1

    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) ???

  • @jeromyclassyca7063
    @jeromyclassyca7063 3 года назад

    This is the only lesson I found difficult that this man taught

  • @karimshaikh3900
    @karimshaikh3900 3 года назад

    Very well explained!

  • @moony1926
    @moony1926 4 года назад

    Super super helpful and clear! Thank you so much!

  • @apoorvsharma3503
    @apoorvsharma3503 9 лет назад +11

    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}

    • @idontevenknow3707
      @idontevenknow3707 6 лет назад +13

      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.

    • @BBaDDaYY
      @BBaDDaYY 6 лет назад +18

      I think he sorted it out himself throughout those years :D

    • @kaizhang6768
      @kaizhang6768 6 лет назад +1

      in a harder way XD

    • @anondoggo
      @anondoggo 5 лет назад

      @@idontevenknow3707 Thanks for the clarification. This confused me a lot as well.

  • @Rakeshrajeev94
    @Rakeshrajeev94 5 лет назад

    Very much helpful. Thanks team 😊

  • @nuradilzholmukhan8672
    @nuradilzholmukhan8672 4 месяца назад

    holy shit what a golden video! THANKS

  • @sahilkanojia2531
    @sahilkanojia2531 7 лет назад

    sir, I will understand good from your excellent explaination thank you so much

  • @dharmikmistry8781
    @dharmikmistry8781 4 года назад

    Thanks for your great efforts 🔥🔥😍🤗

  • @notepad800
    @notepad800 7 лет назад

    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)??

  • @sagarsaha3762
    @sagarsaha3762 6 лет назад +1

    Hey, the website at mycodeshool.com doesn't' work at all. It says "502 Bad Gateway". Please fix this immediately.

  • @225mrraj
    @225mrraj 11 лет назад +1

    can u guide us more on stacks ,queues,trees n other stuff. on data structurea.

  • @AtulKumar-nx5gh
    @AtulKumar-nx5gh 4 года назад

    awesome content

  • @03Karthikeyan
    @03Karthikeyan 9 лет назад

    Thanks man! I had to listen to this couple of times, but it made sense.

  • @PetBuddies
    @PetBuddies 3 года назад

    So good explanation __

  • @2311kamal
    @2311kamal 2 года назад

    the best video ever!!

  • @shiwangiagrawal8549
    @shiwangiagrawal8549 6 лет назад

    Very good video. Thanku soo much. Helped a lot.😊😊

  • @MrAltQQer
    @MrAltQQer 8 лет назад +3

    You're a Monster.

  • @captainjacksparrow713
    @captainjacksparrow713 6 лет назад +1

    thank you

  • @pedroantoniodesouzasilva2068
    @pedroantoniodesouzasilva2068 5 лет назад

    Thank you very much, my friend!

  • @vineethreddymadadi7940
    @vineethreddymadadi7940 4 года назад

    Awesome stuff!

  • @snv1996
    @snv1996 5 лет назад

    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)

    • @mdmurtaza8321
      @mdmurtaza8321 2 года назад

      He is software engineer at google

  • @amanjangid6375
    @amanjangid6375 4 года назад

    Thanks for Making 😊

  • @sayantaniguha8519
    @sayantaniguha8519 4 года назад

    3:48
    You meant instead of writing 1st line as **p = A* ,
    We can also write it as *p=A* ?

  • @gokuafrica
    @gokuafrica 9 лет назад +1

    finally got it. Thank you!!!!!!

  • @pavankumar-hu1sw
    @pavankumar-hu1sw 8 лет назад

    thanks, please upload some more videos

  • @smerabunuwara296
    @smerabunuwara296 6 лет назад

    great tutorials thank u

  • @pveldhose6211
    @pveldhose6211 7 лет назад +1

    sir write a program to find the sum of both diagonals separately of 2D array

  • @xMrJanuaryx
    @xMrJanuaryx 10 лет назад +1

    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;
    }

    • @talhaanwar2178
      @talhaanwar2178 8 лет назад

      +Robert Murch
      int main()
      {
      char c[] = "Robert";
      printf("%p", c);
      return 0;
      }
      Just replace %s with %p.

    • @nafisfaiyaz7543
      @nafisfaiyaz7543 6 лет назад

      when you write %s, the compiler starts looking for null character. so, writing %s will give you the whole array.