I must make a program which registers and then returns the name and age of three different people, using a structure or several structures. The program is already done and finished, it would only be to correct those errors so that it compiles and executes.
#include <iostream>
#include <conio.h>
using namespace std;
struct Persona {
char nombre {20};
int edad;
}persona1,persona2,persona3;
int main()
{
cout<<"Ingrese su nombre: "<<endl;
cin.getline(persona1.nombre,20,endl);
cout<<"Ingrese su edad: "<<endl;
cin>>persona1.edad;
cout<<"Ingrese su nombre: "<<endl;
cin.getline(persona2.nombre,20,endl);
cout<<"Ingrese su edad: "<<endl;
cin>>persona2.edad;
cout<<"Ingrese su nombre: "<<endl;
cin.getline(persona3.nombre,20,endl);
cout<<"Ingrese su edad: "<<endl;
cin>>persona3.edad;
cout<<"Imprimiento datos"<<endl;
cout<<"Datos de la persona 1: "<<endl;
cout<<"Nombre: "<<persona1.nombre<<endl;
cout<<"Edad: "<<persona1.edad<<endl;
cout<<endl;
cout<<"Datos de la persona 2 "<<endl;
cout<<"Nombre: "<<persona2.nombre<<endl;
cout<<"Edad: "<<persona2.edad<<endl;
cout<<endl;
cout<<"Datos de la persona 3 "<<endl;
cout<<"Nombre : "<<persona3.nombre<<endl;
cout<<"Edad: "<<persona3.edad<<endl;
return 0;
}
I would like to know and understand why I get the following errors:
16: error: no matching function for call to 'std::basic_istream<char>::getline(char&, int, <unresolved overloaded function type>)'|
22: error: no matching function for call to 'std::basic_istream<char>::getline(char&, int, <unresolved overloaded function type>)'|
28: error: no matching function for call to 'std::basic_istream<char>::getline(char&, int, <unresolved overloaded function type>)'|
Explanation
improvements
Solution
Or, if you also need it to be with functions and pointers, you can use this option: