Stirring with data structures ( filas
, pilhas
, etc), I got stuck trying to create search functions for these structures.
By default, functions that may contain errors return 0 or -1 when the return type is an integer.
But what if the return type of a function is a struct and an error was encountered?
When searching for a given type of data in a tree, for example, in a function with the following prototype:
typedef struct registro {
int valor;
// outros dados...
} Registro;
// Supondo que o tipo Árvore já foi criado
Registro busca(Arvore a, int valor);
If the record is found in the tree, beauty returns the struct that contains this value. But what if she is not found? I return what?