Problem due to queuing

1

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';
  }
 }
}
    
asked by anonymous 04.04.2017 / 01:12

1 answer

0

The error message you entered does not match the text: there is no command

FilaAluno[fimfila].nome = FilaAluno.nome;

In the lines of code you have shown ...

But there is an error on this line

FilaAluno[fimfila].nome = FilaAluno[i].nome; //problema

What should be

memcpy(FilaAluno[fimfila].nome, FilaAluno[i].nome, 100);

But for this to work you need to insert this line at the beginning of the program:

#include <cstring>
    
04.04.2017 / 02:48