Thread: variable/string trouble

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    Question variable/string trouble

    Hi,
    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
    Location
    New Zealand
    Posts
    6,318
    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
    Location
    *nullptr
    Posts
    2,657
    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