4 ms·
You can pass structs by value. Why not arrays?
by acconsta 11y ago
You can pass structs by value. Why not arrays?
- 36erhefg 11y agoYour answer is merely a simple online search away.
- acconsta 11y agoWhat's weird is five hours after asking that question, no one has provided a reasonable explanation of why C requires arrays to become pointers on function boundaries. My "online search" found Walter Bright, who knows a thing or two about C compilers, wondering the same thing: https://news.ycombinator.com/item?id=7572011 https://news.ycombinator.com/item?id=7572011
- 36erhefg 11y agoImprove your searching capabilities. https://programmers.stackexchange.com/questions/245602/why-cant-arrays-be-passed-as-function-arguments-in-c https://programmers.stackexchange.com/questions/245602/why-c... ( https://stackoverflow.com/questions/7454990/why-cant-we-pass-arrays-to-function-by-value https://stackoverflow.com/questions/7454990/why-cant-we-pass... ) And partially this thread. As for Walter; Stop using C like you want it to be used, and instead how it is meant to be used. The article takes a strawman position. Anyone who takes their time and learns C, knows that arrays decay.
- acconsta 11y agoSo it comes down to historical compatibility with B? Wow.