Click here to Skip to main content
15,895,797 members
Articles / Programming Languages / C

strcmp is not working the way it should

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Jan 2013CPOL 3.8K  
What is the return value of strcmp in c.I wrote the following code in c. #include #include #include #include #include #include #include #include#define...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
11 Jan 2013OriginalGriff
Working just from your code fragment, it is difficult to work out what your problem is: the only reference to strcmp you have does not use argv at all - it uses an array of strings you create and fill.But are you sure you are using it right?strcmp(argument[0], "cd")will return 0 if the...
Please Sign up or sign in to vote.
11 Jan 2013Richard MacCutchan
You should always check the documentation[^] first. As you can see, the strcmp() function returns an integer value not a boolean as your code assumes.There is no definition of the variables (buffer, argument) in your code; where are they defined?You are calling the strcmp() function before...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions