0
I have an algorithm that reads name, sector and number of 10 employees, I’m trying to read in a function but I’m not succeeding, when I try to print only out numbers. This is a piece of content that I didn’t understand at all, so it may be that they have blatant errors.
#include <bits/stdc++.h>
using namespace std;
typedef struct
{
string nome;
string setor;
int cartao;
}funcionario;
void inserir(funcionario func)
{
cin >> func.nome;
cin >> func.setor;
cin >> func.cartao;
}
int main()
{
setlocale(LC_ALL,"Portuguese");
funcionario func[10];
int opcao=0, p=0;
do{
cout << "O que você deseja fazer?\nDigite \"1\" para inserir.\nDigite\"2\" para buscar.\n";
cin >> opcao;
if(opcao != 1 && opcao != 2){
cout << "Valor digitado inválido, digite novamente.\n";
}
else if(opcao == 1){
inserir(func[p]);
p++;
}
}while(p < 10);
}
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero