Thread: variable/string trouble

  1. #1
    Registered User
    Join Date
    Nov 2012

    Question variable/string trouble

    I am creating a program to help me memorize stuff but I need a variable that will hold full sentences with spaces.
    Also i want to be able to check weather the user input macthes the correct answer.
    Thank You.

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    New Zealand
    std::string is what you want. You use the == operator to compare them (case-sensitive)
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Depending on your exact usage, std::vector<std::string> may be more appropriate.
    (For example, what if the user enters an exra whitespace somewhere.)

    Comparing would then need a loop, though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-25-2011, 10:33 PM
  2. Replies: 10
    Last Post: 03-28-2010, 01:35 AM
  3. Having trouble converting a variable
    By KasMage in forum C++ Programming
    Replies: 6
    Last Post: 07-14-2008, 03:43 PM
  4. Replies: 12
    Last Post: 10-14-2003, 10:17 AM
  5. Trouble with a class variable
    By TravisDane in forum C++ Programming
    Replies: 9
    Last Post: 12-08-2002, 12:59 AM