string variable checks

This is a discussion on string variable checks within the C++ Programming forums, part of the General Programming Boards category; something as basic as having the user enter yes or no in full string instead of single char.is there a ...

  1. #1
    Unregistered
    Guest

    Question string variable checks

    something as basic as having the user enter yes or no in full string instead of single char.is there a short cut i can use instead of comparing 2 arrays against each other?

    such as if (answer == 'yes')

    or if(answer[1]=='y'&&answer[2] ect?

    ???????
    newbie programmer of ill respute and talent

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    No, you have to use strcmp(). I'm not sure, but it might be possible to overload == so you can compare strings. Don't ask me how, though .
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 03:13 PM
  2. assigning a string to a variable
    By xp5 in forum C Programming
    Replies: 12
    Last Post: 08-30-2007, 01:13 AM
  3. RicBot
    By John_ in forum C++ Programming
    Replies: 8
    Last Post: 06-13-2006, 06:52 PM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 01:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21