▲ 93 r/C_Programming
Why can't you pass/return arrays to/from functions? Why is it designed like this?
I understand that the answer to "Why can't you do this" is "the standard says so" but I'm not asking about the mechanics of the language, I'm asking about its design.
Array sizes are known at compile time and a struct where all members are the same type is identical to an array in memory (correct me if I'm wrong). C has no problems returning structs and taking them as arguments in a function. Why can't it do the same for arrays?
I also feel like it would be way more intuitive and convenient if you could return arrays from functions.
C language experts do please enlighten me as to the reason arrays decay to pointers instead of just staying as arrays.
u/GreenMario_ — 4 days ago