0
So, imagine that there is already a function that registers students and there is this struct
of students below and a variable that counts how many registered students we have and the constant that controls the size of the type struct array aluno(N_ALUNOS)
typedef struct {
char nome[25];
int matricula;
float notas[2];
char situacao[10];
} Aluno;
Aluno Alunos[N_ALUNOS];
int alunosCadastrados = 0;
This function(is the problem) takes the position excluded from the vector, the idea of the function is that from a position excluded from the vector all elements that are in a higher position return a position, vector that is the one quoted above
void atualizaArray(int posExcluida){
// Se a posição excluida não for a última
if(posExcluida < alunosCadastrados - 1){
// Percorre todo vetor
for(int j = 0; j < alunosCadastrados; j++){
// se o índice atual for maior que a posição excluida do vetor
if(j > posExcluida){
Alunos[j - 1].matricula = Alunos[j].matricula;
strcpy(Alunos[j - 1].situacao, Alunos[j].situacao);
Alunos[j - 1].notas[0] = Alunos[j].notas[0];
Alunos[j - 1].notas[1] = Alunos[j].notas[1];
strcpy(Alunos[j - 1].nome, Alunos[j].nome);
}
}
}
}
In tests done I was defining N_ALUNOS
as 3 and when filling the 3 indexes of the vector I tried to delete the first index and when checking the two indexes that remained , were repeated with the values of the 2 index, any suggestion?