When using a data type string
, if I enter spaces, it does not let me re-enter a data.
struct series{
string nombre;
char tematica[15];
int estreno;
};
struct fans{
string nombre;
string direccion;
string sexo;
int nacimiento;
struct series seriesTV[10];
}f[10000];
int main(){
do{
cout<<"Cuantas serie sigue? "; cin>>n;
}while( n <= 0 || n > 10);
cin.ignore();
while(cont != n){
cout<<cont+1<<". Digite el nombre de la serie: "; cin>>f[i].seriesTV[cont].nombre;
cin.ignore();
cont++;
}
system("pause");
return 0;
}
Try using getline()
It includes
<string>
And replace:
For this:
getline.cin is used to be able to store the data you want to save with the string, you can also use fflush to clear the buffer.