Thread: strcmp clarification

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    4

    strcmp clarification

    Ola!

    if I use the function

    int my_strcmp(char * s1, char * s2)
    {
    /* S1 = Abba S2 = Ball*/
    return strcmp(s1,s2);
    }

    What will the function return? Will it be a +ve integer or negative? (Basically I'm asking how and what does strcmp return when you know the strings aren't equal?)

    Thanks for your help!

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    42
    strcmp(s1, s2)

    returns 0 if they are equal. returns 1 if s1 is greater than s2 and returns -1 if s1 is less than s2.
    http://www.KBeutler.com

  3. #3
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    >Ola!

    Word!

    Since A<B, it should return a negative.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fucntion returns -1, Why?
    By Taper in forum C Programming
    Replies: 16
    Last Post: 12-08-2008, 06:30 PM
  2. help with switch statement
    By agentsmith in forum C Programming
    Replies: 11
    Last Post: 08-26-2008, 04:02 PM
  3. problem with strings
    By agentsmith in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 12:07 PM
  4. help with strcmp
    By blork_98 in forum C Programming
    Replies: 8
    Last Post: 02-21-2006, 08:23 PM
  5. strcmp
    By kryonik in forum C Programming
    Replies: 9
    Last Post: 10-11-2005, 11:04 AM