0
People have that function tem_numero_na_lista
it turns out that it is printing on the screen only the last value I entered in the list.
The effect I want is to print out whether or not you have numbers inside the list.
Behold:
tipo_lista * tem_numero_na_lista (tipo_lista * p, int valor)
{
while (p != NULL)
{
if (p -> info == valor)
{
printf("Tem %d numero(s) na Lista\n", p->info);
return true;
}
p = p -> prox;
}
printf("Não tem numero na Lista!\n");
return false;
}
int main() {
tipo_lista * recebida = inicializaLista();
int valor; //uso esse?
bool valor3; //uso esse?
case 9:
tem_numero_na_lista(recebida, valor);
system("pause");
break;
}
You pass a number to the function and it says whether it is in the list or not. Here is working normal function. Maybe you are not testing right.
– Lucas Trigueiro
I added my test done on main, maybe I’m not knowing to test even.
– André
Here it returns the last value I typed, understand? I enter value 2, then value 8, choose option 9 the correct output is 2, 2 numbers, not 8. that’s what happens, is printing the last value I typed '8'.
– André
But the function you created checks if a value is in the list; it has nothing to do with the total amount of values. You made these codes yourself?
– Woss
This function I pass the value and check if it has in the list, this is it.
– André