I'm creating a program that puts each student's grades in a different file. The user puts the code of the student and this code turns the name of a file that is not txt (I do not know how does it do txt). But I'm not able to delete this file. For example, the user will enter the student code and I want the file with that code to be excluded. I've tried using the remove () function, but it only works for the txt file. I also tried using the unlink () function but I did not quite understand how it works.
Ha ha, obg !!
void apagar()
{
char nusp[8];
printf("--------- CONSULTA ---------\n\n");
printf("Digite o NUSP do aluno(a): ");
gets(nusp);
FILE *consultar;
consultar = fopen(nusp,"r");
if (consultar==NULL)
{
printf("\nAluno ainda nao cadastrado.");
}
else
{
printf("\n");
remove(nusp);
printf("\nAluno removido com sucesso!\n\n");
system("pause");
}
}