c++ how do you store a full string into a string array using getline? -
after gets first string , first double program doesn't other strings.
for (int = 0; i< num_movies; i++) { cout << "enter name of movie: "; getline(cin, names[i]); cout << "how did " << names[i] << " earn <in millions>: "; cin >> earnings[i]; cout << endl; }
the second time call getline
reading newline character because cin >>
not discard newline characters after value has read.
so end in cycle of reading bad data. try this:
getline(cin >> std::ws, names[i]);