Thread: comparing character arrays

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    15

    Question comparing character arrays

    would someone be able to show me were to start please i have a problem when im trying to compare 2 charater arrarys.The first character array has read in module codes from a text file the second has stored user input. Ive called a function of type bool to compare the two arrays if they match i want to return true if they dont then false.

    Ive tried to use a subscript but it ends up printing all the strings stored in the array.

  2. #2
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Here

    And I´m sure you would find it here too.

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    strcmp() compares two strings (NULL terminated character arrays). If you only have character arrays, use memcmp() instead.
    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. Manipulating Character arrays in functions.
    By kbro3 in forum C++ Programming
    Replies: 11
    Last Post: 08-16-2008, 02:24 AM
  2. Question on character arrays
    By Countfog in forum C Programming
    Replies: 9
    Last Post: 04-30-2008, 01:06 AM
  3. Character Arrays
    By JHaney in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2005, 12:53 PM
  4. multidimentional character arrays
    By ckeener in forum C++ Programming
    Replies: 7
    Last Post: 03-11-2005, 08:49 PM
  5. A question concerning character arrays
    By ellipses in forum C Programming
    Replies: 3
    Last Post: 03-08-2005, 08:24 PM