my code is not working. I have an error of -fpermissive ("invalid conversion from 'int' to 'persona*' [-fpermessive]"). Can you help me? This is my first real program, sorry for the errors and the bad english.
#include <iostream>
using namespace std;
struct persona
{
char nome[20];
unsigned int eta;
unsigned int altezza;
unsigned int peso;
};
int totale = 0;
struct persona prs[100];
void leggere_dati(persona* prs)
{
cout << "Persona numero: " << (totale + 1) << endl;
cout << "Nome: " << prs->nome << endl;
cout << "Eta': " << prs->eta << endl;
cout << "Altezza: " << prs->altezza << endl;
cout << "Peso: " << prs->peso << endl;
cout << "-----------------------------------------------\n";
}
void inserire_dati(persona* prs)
{
cout << "Nome? ";
cin >> prs -> nome;
cout << "\nEta'? ";
cin >> prs -> eta;
cout << "\nAltezza? ";
cin >> prs -> altezza;
cout << "\nPeso? ";
cin >> prs -> peso;
}
int main()
{
int risposte = 0;
char risp = 0;
do{
inserire_dati(totale);
cout << "Inserire un'altra persona? (S/N)" << endl;
cin >> risp;
if (risp == 'S')
{
risposte += 1;
totale++;
continue;
}
} while (risp == 's' || risp == 'S');
if (risp == 'n' || risp == 'N')
{
for (totale = 0; totale <= risposte; totale++)
leggere_dati(totale);
}
}
totale, what type is it? Why do attempt to pass it as an argument to the functioninserire_dati? Are you trying to pass e.g.&prs[totale]?