Mar 24, 2016 at 11:01pm UTC
Hello, I'm having troubles with this part of my program reading song names including spaces.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
for (int i = 0; i < 3; i++)
{
cout << "Enter Artist first name: " ;
cin >> y;
x[i].setArtist(y);
cout << "Enter Artist last name: " ;
cin >> y;
x[i].setArtistl(y);
cout << "Enter Song name: " ;
getline(cin, y, '\n' );
x[i].setSong(y);
output << x[i].getArtist() << " " ;
output << x[i].getArtistl() << endl;
output << x[i].getSong() << endl << endl;
}
Every time I run the program it will output:
Enter Artist first name: Justin
Enter Artist last name: Bieber
Enter Song name: Enter Artist First name:
Not sure if I'm using getline properly
Thanks!
Last edited on Mar 24, 2016 at 11:07pm UTC
Mar 25, 2016 at 12:04am UTC
Does that apply to using classes and arrays?
I'm assuming pause won't work since i have a loop to send the information to 3 arrays.
I'm also outputting them to a txt file.
I should have been more clear, my apologies.
Last edited on Mar 25, 2016 at 12:47am UTC
Mar 25, 2016 at 12:47am UTC
I have solved it
I just decalred the strings how you did and changed the getline
Thanks!