You are looking for std::getline()
. For example:
#include <string>
std::string str;
std::getline(std::cin, str);
I've little idea what you mean when you say I must also be able to store the value through a pointer.
Update: Looking at your updated question, I can imagine what is happening. The code that reads the choice, i.e. the number 1, 2, etc. is not reading the newline. Then you call getline
which consumes the newline. And then you call getline
again which fetches the string.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…