Multidimensional arrays in C

Поделиться
HTML-код
  • Опубликовано: 11 фев 2025
  • Check out our Discord server: / discord

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

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

    that was more helpful than 90% of the other search results. tyvm.

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

    I am very grateful for your videos, in college I have to write programs that I would not be able to make without your videos!

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

    thanks!
    in C everything has to be complicated... not a moment of dullness!

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

    You are great at explaining and i relly love your way of teaching

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

    Thanks for this video and the whole series really, I'm trying to teach myself C through the Dive Into Systems online book and this was an especially complicated subject to grasp, I would only point out (as I noticed you also did this in your "Dynamically allocated multi-dimensional arrays in C" video) that the explanation would be slightly easier to follow if you used arrays with different row and column sizes, since it's no too hard to get lost following rows or cols when dealing with square (3x3) arrays. Cheers!

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

    man, the first time you fast forwarded your typing i felt incredibly inadequate for the split second i hadn't realized it was fast forwarded hahaha, just thought id share that with the group

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

      Haha, I bet there are people out there that can actually type that fast :D

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

    Thankyou for the lesson, how do you find the neighbouring elements of a cell in a multidimensional array?

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

      The idea is to have offset arrays for each axis:
      int offsetx = { -1, 0, 1, 0 };
      int offsety = { 0, 1, 0, -1};
      Then you just iterate over it with a for loop up to 4 while adding these offsets to the coordinates in the array:
      arr[x + offsetx(i)][y + offsety[j]]
      We might make a video on this topic.

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

    thank you very much

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

    Oh thx man! U really helped me!

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

    Thank you for the great lessons!

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

    Loved it. 👍

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

    Really nice info. What if I need to periodically fill a 3d array with 1s and 0s so that I homogenously distribute clusters of 1s in a space of 0s? Thank you in advance.

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

      Same principle applies. Just have a 3 dimensional array that is dynamically allocated and have it store chars (1 byte) for maximum memory efficiency

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

    you explained very well!! my most of the queries have been clarified. But still I request you to make a video for double and triple pointer examples in C and dereferencing..

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

      Thank you! There's this video on double pointers that may help: code-vault.net/lesson/tapcyuvuo6:1603733527497

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

      @@CodeVault wonderful! You are so articulative and skilled in your explanation that even beginners can understand without a painful effort

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

    Isn't it required of you to cast the void* in this case, malloc(), to the Lvalue during the initialization expression?

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

      No. Only the C++ compiler makes that a requirement I think. In C, void* are cast automatically to what you assign them to.

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

    You could create `int\*\*` view of `int arr[3][3]` simply as `int\* arr_p[] = { arr[0], arr[1], arr[2] }`. And pass `arr_p` to `process()`. There is no need to play with `malloc()`

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

      Yeah, that's probably a better way of doing it. Good suggestion!