I'm trying to create a queue with structs, but the assignment slice is not working on lines 17/18, I'm not finding the error. Is the logic I'm using correct?
error: request for member 'nome' in 'FilaAluno', which is of pointer type 'aluno' (maybe you meant to use '->' ?) FilaAluno[fimfila].nome = FilaAluno.nome;
I'm using Atom with Myngw.
#include <iostream>
using namespace std;
#define max_fila 2
struct aluno {
char nome [100];
int cod;
int turma;
} ;
bool enfileirar(aluno FilaAluno[], int &i, int &fimfila){
if (fimfila == max_fila){
std::cout << "fila cheia" << '\n';
return false;
}
else{
FilaAluno[fimfila].nome = FilaAluno[i].nome; //problema
FilaAluno[fimfila].cod = FilaAluno[i].cod; //problema
FilaAluno[fimfila].turma = FilaAluno[i].turma;
fimfila++;
}
return true;
}
int main(){
aluno FilaAluno [max_fila]; //fila
int inifila = 0;
int fimfila = 0;
for (int i = 0; i < max_fila; i++) {
/* code */
std::cout << "Codigo:" << '\n';
std::cin >> FilaAluno[i].cod;
std::cout << "Nome:" << '\n';
std::cin >> FilaAluno[i].nome;
std::cout << "Turma:" << '\n';
std::cin >> FilaAluno[i].turma;
if(enfileirar (FilaAluno, i, fimfila)){
std::cout << "Item adicionado com sucesso!" << '\n';
}
}
}