0
In the delete function, the user will inform an AR that he wants to delete, when the AR exists in the memory he deletes, that part of the code works... The problem is when it does not find in memory the RA... The system locks
void deletar(void){
system("cls");
//RA que o usuario quer deletar
int n;
printf("Digite o RA que deseja deletar: ");
scanf("%i", &n);
do{
//Esta parte esta ok
if(p->ra == n){
//deleta a struct da memoria
free(p);
printf("\n\n\nAluno deletado com sucesso\n");
system("pause");
system("cls");
//limpando a tela e voltando para o menu principal
main();
}
//Quando ele nao acha o RA o programa trava.
//unica coisa que falta pra finalizar o metodo
if (p->anterior==NULL){
printf("\n\n\nERRO 404: RA nao existe no sistema\n");
system("pause");
system("cls");
//limpando a tela e voltando para o menu principal
main();
}
//vai pra proxima struct
p = p->anterior;
}while(1);
}
I put a condition for if the previous one is NULL means that it has already traversed all the structs, then it does not exist, but it is not working
assuming that "delete" was called by "main", then you use "Return" to go back to main, not the name of the main function, otherwise there is a recursive call
– zentrunix
but I need you to go back to the main menu, the program can’t close after that, you understand?
– Arthur
worked by putting Return...
– Arthur