Function return type for a linked list

1

What kind of return to use in a threaded list? For example, enter at the top of the list.

void inserir(pessoas **pessoa, int valor) 

No return (% with%). Or return a pointer from the list.

pessoas* inserir(pessoas **pessoa, int valor)

What would be the most appropriate?

    
asked by anonymous 07.12.2016 / 15:29

1 answer

1

The first one may be well suited because it probably modifies pessoa with the new element and does not have to return anything.

The second is only useful if you are not changing the data structure, or if you want to let the inserir() function be used as an expression somewhere. The first can only be used as statement .

If you use the former it may be useful to return a green or false if the operation occurred ok. In some scenarios you may not be able to complete it and it would be interesting to report that an error occurred in a simple way . p>     

07.12.2016 / 15:40