2 ms·
The only particularly messy part in the C code there is the (int*(*)[]) type cast. My intuition (because I don't usually have to deal with this kind of nonsens
by MauranKilom 5y ago
The only particularly messy part in the C code there is the (int*(*)[]) type cast.
My intuition (because I don't usually have to deal with this kind of nonsense) is "cast to a pointer to an array of int pointers". cdecl confirms that: https://cdecl.org/?q=int*%28*x%29%5B%5D https://cdecl.org/?q=int*%28*x%29%5B%5D
So we cast a (pointer to pointer to int) to (pointer to array of int pointers) [we can ignore the detour through void*] and then immediately dereference through all three layers. Which gives us back the only int in the program.
Excellent example of how to be a Three Star Programmer I guess: https://wiki.c2.com/?ThreeStarProgrammer https://wiki.c2.com/?ThreeStarProgrammer
- pmarreck 5y agoTIL about cdecl.org I don't code in C day to day but this will help for the odd time I need to understand C code!