string compare

This is a discussion on string compare within the C Programming forums, part of the General Programming Boards category; Hi All! Is there a standart function, to compare two strings together case INsensitive? strcmp and strncmp compare casesensitive! thx...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Location
    Austria
    Posts
    55

    string compare

    Hi All!

    Is there a standart function, to compare two strings together case INsensitive?

    strcmp and strncmp compare casesensitive!


    thx

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    EDIT:
    oopsie in codie

    Okay, there is a quick non-standard function called stricmp() that may be supported by your compiler. It ignores case when comparing strings.
    Last edited by Dante Shamest; 10-12-2003 at 12:57 PM.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Location
    Austria
    Posts
    55

    Thumbs up

    Yeah works great

    i guess strnicmp would work too?! [Edit: yes works ]

    thx
    Last edited by IceBall; 10-12-2003 at 01:32 PM.

  4. #4
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    you could also for example make everything upper or lower case and just use strncmp
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>non-standard function called stricmp()
    >>i guess strnicmp would work too?!
    >>you could also for example make everything upper or lower case and just use strncmp
    The best way, imo, is to create your own Stricmp() function, that way it's portable. You don't need to convert the two strings to lowercase first, just do that as you go through the arrays:
    Code:
    /* something like: */
    if (tolower(s1[i]) != tolower(s2[i]))
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

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, 04:13 PM
  2. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 04:58 PM
  3. problems with overloaded '+' again
    By Brain Cell in forum C++ Programming
    Replies: 9
    Last Post: 04-14-2005, 06:13 PM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. "Operator must be a member function..." (Error)
    By Magos in forum C++ Programming
    Replies: 16
    Last Post: 10-28-2002, 02:54 PM

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