Another n00b question: storing text as a variable

This is a discussion on Another n00b question: storing text as a variable within the C++ Programming forums, part of the General Programming Boards category; for my first game-type programming project, I'm going to try to make a simple text adventure that's only a few ...

Another n00b question: storing text as a variable

for my first game-type programming project, I'm going to try to make a simple text adventure that's only a few screens long. How can I make it so that the user can input text and it can be stored as a variable that affects the outcome, since char variables only store one character? is there some secret I'm missing? thanks for helping out a complete beginner!

The C way is to store text in char arrays that have a final character of '\0' to denote the end of the sequence of chars. This was messy if you didn't take heed that you handled them right. If you forgot a '\0' or you overran the buffer, you'd be in for some headaches. That's why C++ has the std::string class. It encapsulates the ugliness of storing text and manipulating it, and it's much safer to use.