c++ - std::cin input with spaces? -
#include <string> string input; cin >> input;
the user wants enter "hello world". cin
fails @ space between 2 words. how can make cin
take in whole of hello world
?
i'm doing structs , cin.getline
doesn't seem work. here's code:
struct cd { string cdtitle[50]; string artist[50]; int number_of_songs[50]; }; cin.getline(library.number_of_songs[libnumber], 250);
this yields error. ideas?
you have use cin.getline()
:
char input[100]; cin.getline(input,sizeof(input));
Comments
Post a Comment