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!
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
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.
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.
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..
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()`
that was more helpful than 90% of the other search results. tyvm.
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!
thanks!
in C everything has to be complicated... not a moment of dullness!
You are great at explaining and i relly love your way of teaching
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!
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
Haha, I bet there are people out there that can actually type that fast :D
Thankyou for the lesson, how do you find the neighbouring elements of a cell in a multidimensional array?
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.
thank you very much
Oh thx man! U really helped me!
Thank you for the great lessons!
Loved it. 👍
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.
Same principle applies. Just have a 3 dimensional array that is dynamically allocated and have it store chars (1 byte) for maximum memory efficiency
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..
Thank you! There's this video on double pointers that may help: code-vault.net/lesson/tapcyuvuo6:1603733527497
@@CodeVault wonderful! You are so articulative and skilled in your explanation that even beginners can understand without a painful effort
Isn't it required of you to cast the void* in this case, malloc(), to the Lvalue during the initialization expression?
No. Only the C++ compiler makes that a requirement I think. In C, void* are cast automatically to what you assign them to.
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()`
Yeah, that's probably a better way of doing it. Good suggestion!