-
February 1st, 2010, 05:47 PM
#1
newbie Q: how can you cout different strings based on what you cin?
I'm trying to write a rather simple code, that allowed you to cin your name, and get something out of cout based on what you put in. Basically I want to have a response correlated to each of my friends names.
-
February 1st, 2010, 05:59 PM
#2
Re: newbie Q: how can you cout different strings based on what you cin?
If you only need to give known responses to known names, then a std::map<std::string, std::string> will do nicely. For a "simpler" (actually more code, but most beginners prefer it) approach to the same basic idea, a series of if/else statements will work too.
If you need to determine the result at runtime as a function of the input, then you'll be more specific about the requirements.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|