alternative to strcmpi

This is a discussion on alternative to strcmpi within the C Programming forums, part of the General Programming Boards category; hello i am trying to compile my program but the compiler does not accept strcmpi() what is another function i ...

  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,045
    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
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    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,045
    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, 08:46 AM
  2. HELP with strlen and strcmpi
    By unejam2005 in forum C++ Programming
    Replies: 2
    Last Post: 12-11-2005, 02: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, 01:19 PM

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