Thread: how strcmp() compairs two strings

  1. #1
    Registered User sagar474's Avatar
    Join Date
    Jun 2011
    Location
    Kakinada
    Posts
    56

    how strcmp() compairs two strings

    I need to wright my won strcmp function. so i need to know how strcmp works.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    How do you think it works?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    111
    It takes two strings and compares them by each element. If the string matches, it gives a certain value, if it doesn't match it gives a different value.

    Look up "strcmp() in c" it will give more details.

  4. #4
    Registered User sagar474's Avatar
    Join Date
    Jun 2011
    Location
    Kakinada
    Posts
    56
    what is that value? how it is assigned? and how it is calculated?

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by sagar474
    what is that value? how it is assigned? and how it is calculated?
    Obviously, you would loop over the two strings. I suggest that you venture an answer yourself. If you want spoonfeeding for this one, then I might as well write the function for you, and that will spoil your fun.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User sagar474's Avatar
    Join Date
    Jun 2011
    Location
    Kakinada
    Posts
    56
    Quote Originally Posted by laserlight View Post
    Obviously, you would loop over the two strings. I suggest that you venture an answer yourself. If you want spoonfeeding for this one, then I might as well write the function for you, and that will spoil your fun.
    yes you are right! thank you ? but I have no time! any how, if complete it. I will post the source in this thread so any others can use it.
    Last edited by sagar474; 09-22-2011 at 11:31 AM.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    We've all done this exercise before. Now it's your turn.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with strcmp()
    By shel5210 in forum C Programming
    Replies: 8
    Last Post: 04-17-2010, 11:06 AM
  2. strcmp()
    By norhos in forum C Programming
    Replies: 15
    Last Post: 03-15-2008, 09:15 AM
  3. strcmp
    By kryonik in forum C Programming
    Replies: 9
    Last Post: 10-11-2005, 11:04 AM
  4. >>strcmp(); makes it alot easier to compare 2 strings
    By Waspntr in forum C++ Programming
    Replies: 6
    Last Post: 02-06-2003, 08:11 PM
  5. problem comparing strings with strcmp
    By mikefen in forum C Programming
    Replies: 2
    Last Post: 12-03-2001, 10:45 PM