79671441

Date: 2025-06-19 01:37:47
Score: 1
Natty:
Report link

It simply is not possible or better not a good idea to return anything else than some kind of size_t ¹.
That is how C / C++ is working. C (and I let CPP off, because it is just C with a better Compiler), so C as Language is the fastest Language, because it is (Compiler dependent) the closest way to assembler, we do not want to program anymore.
If you call a function in C, you can put as many arguments to the function as you want (as the stack² size allows)
And you only can return data of fixed size. (as the stack² size allows)
Typically, one register. And if you want more, there is again some place in stack reserved.
But only some space.
What I try to say is, that whereas the number of input is somehow unlimited, the return value is.

¹size_t is am approach to get the best size for the CPU. Once this was "BYTE" (on pdp-11 a Byte had 11 bits.) Since BYTE is more or less normed to 8 8bit, it was "int", but also "int" is not was it was before. And size_t will get the same problem.

²the stack is a memory, that is shared for functions, and interrupts and limited.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Me too answer (2.5): get the same problem
  • High reputation (-1):
Posted by: halfbit