#include <string>
std::string input;
std::cin >> input;
The user wants to enter "Hello World". But cin
fails at the space between the two words. How can I make cin
take in the whole of Hello World
?
I'm actually doing this with structs and cin.getline
doesn't seem to work. Here's my code:
struct cd
{
std::string CDTitle[50];
std::string Artist[50];
int number_of_songs[50];
};
std::cin.getline(library.number_of_songs[libNumber], 250);
This yields an error. Any ideas?
library
so that it's clear that it is of the typecd
getline
into anint
. Of course that fails.CDTitle
, a singleArtist
and a singlenumber_of_songs
. Then have an array (or better yet astd::vector
) of the structure.