re: Double Pointers in C/C++ VIEW POST

re: That's not a maybe ;-) I was asking about the design decision itself.

The return value of getline() is the number of characters read. Because this return value is already in use, they decided an output parameter for the contents would be sufficient.

A comment above made sense. It was in use doesn't justify the design.

A struct is several bytes long, and you'd need to add in the cost of getline's return value as well. These values have to be pushed onto the stack, and then pulled back off and copied again into the receiving struct. That costs valuable processor cycles, but also it's a hidden cost that's not intuitive from reading the code, and therefore goes against C's design.

code of conduct - report abuse