Good afternoon. I'm doing a project for college where the teacher asked to create an algorithm with dynamic lists, where a list should contain clients and other products. The purpose of the project is to make CRUD of both lists, with the condition that the client can not be deleted if it has any product attached to it. The rest of the algorithm I was able to do, but I packed the deletion. Could you help me? Since the code is kind of big (about 600 lines), I put it in Git, instead of posting it here.
I thank you very much for the patience and all the help you can give me!
EDIT: The part that is giving me problems is how to check if the customer has products. I need to delete it if it does not and keep it (showing an error message) if there are related products. In my code, the function that is responsible for this (and not working) is:
struct listacliente* remove_ordenado(struct listacliente *inicio, int x)
{
struct listacliente *p,*q;
p = inicio;
q = inicio;
while(p != NULL)
{
if (p->info.codigo != x)
p = p->proximo;
else if(p->prod != NULL)
{
printf("O cliente tem produtos cadastrados e não pode ser removido.\nPor favor, remova todos os produtos e então tente novamente.");
break;
}
else
{
inicio = removeInicio(inicio);
return inicio;
}
}
if (p == NULL)
printf("\nCliente não encontrado!");