At the moment I was making a double linked list and when I started to try it I had a problem when reading the strings
, I could not do that in the temp->nombre
section I could read the line break, example if I wanted to put a name like "Juan Manuel" the program only read the first and ignored the other text entries. I understand that you need to use getline()
for this but how? I've already tried it and it's the same
They could help me solve this.
cout<<" Dame tu nombre "<<endl;
cin>>temp->nombre;
cin.ignore();
cout<<" Dame tu apellido "<<endl;
cin>>temp->apellido;
cin.ignore();
cout<<" Dame tu ID"<<endl;
cin>>temp->id;
cout<<" Dame tu Ruta"<<endl;
cin>>temp->ruta;
temp->num++;
lista->anterior=temp;
temp->siguiente=lista;
lista=temp;
}
cout<<"\t \t Conductor numero ["<<temp->num<<"]"<<endl;
cout<<"\t \t El nombre es : -> "<<lista->nombre<<endl;
cout<<"\t \t El Apellido es : -> "<<lista->apellido<<endl;
cout<<"\t \t El Id es -> "<<lista->id<<endl;
cout<<"\t \t La ruta es : -> "<<lista->ruta<<endl;
return lista;
Here is the complete code, in case it helps.