CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2010
    Posts
    21

    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.

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    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
  •  





Click Here to Expand Forum to Full Width

Featured