| AndroidZ (62) | |||
|
I'm working on a text game to get myself back into the basics of c++ and hopefully learn new things along the way. I want to be able to process two-part commands like 'open door' without having an IF statement for each thing I can open. Instead, there should be a function called for open that then checks for what is being opened. Is it possible to use an array of characters for this, or do I need to use something like substring? It looks like the standard string type only stores the first word. Defining char arr[15] and using cin to store 'open door' still only stores the first word. I'm not sure where to start on this one. Any and all help is appreciated. Here's my code so far.
| |||
|
Last edited on
|
|||
| JLBorges (1754) | |||
|
What you need immediately: std::getline(): http://www.cplusplus.com/reference/string/getline/ std::istringstream: http://www.artima.com/cppsource/streamstrings3.html > hopefully learn new things along the way Hopefully, there are a few more new things here: std::map<>: http://www.cplusplus.com/reference/map/map/ std::function<>: http://en.cppreference.com/w/cpp/utility/functional/function std::bind(): http://en.cppreference.com/w/cpp/utility/functional/bind initializer lists: http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=424 range based for: http://www.stroustrup.com/C++11FAQ.html#for type deduction: http://www.stroustrup.com/C++11FAQ.html#auto
| |||
|
|
|||
| AndroidZ (62) | |
| Thank you. Looks like I have a lot of reading to do. | |
|
|
|