Thread: alternative to strcmpi

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    10

    alternative to strcmpi

    hello i am trying to compile my program but the compiler does not accept strcmpi()
    what is another function i can use???

  2. #2
    Registered User
    Join Date
    Feb 2005
    Posts
    38
    Perhaps, you have a typo. Try
    Code:
    strcmp()
    Although, there is a safer function
    Code:
    strncmp()
    I like to play pocket pool.

  3. #3
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    strcmpi() is a case-insensitive version of strcmp(). If your compiler's library doesn't have strcmpi(), then you'll either have to write your own, or settle for a case-sensitive string comparison. The macros/functions in <ctype.h> such as tolower(3) should be useful in writing a portable strcmpi() implementation.
    Insert obnoxious but pithy remark here

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Some compilers have stricmp() instead. But the best idea is to write your own version.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    10
    so how do i write my own version to it?

  6. #6
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    There's also strcasecmp

    Well, a good start would be to iterate through each string, comparing each character one at a time, but instead of just comparing them for equality, pass each character through either toupper or tolower, to make it case insensitive.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    And _stricmp(), for MSVC.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-30-2007, 09:46 AM
  2. HELP with strlen and strcmpi
    By unejam2005 in forum C++ Programming
    Replies: 2
    Last Post: 12-11-2005, 03:01 AM
  3. ASP.NET alternative to gallery.menalto.com ???
    By gicio in forum C# Programming
    Replies: 0
    Last Post: 05-15-2005, 11:31 AM
  4. Alternative forms of printf.
    By OOPboredom in forum C Programming
    Replies: 5
    Last Post: 05-07-2004, 01:21 PM
  5. strcmpi()
    By Sicilian in forum C++ Programming
    Replies: 4
    Last Post: 04-04-2002, 02:19 PM