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]); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -