ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
thanks .... sorry. If I wanted to write my own strcmp function just to see how it works I think I could search thru the array and compare each character with the user entered array to see if it's a match and give an error if it isn't.
Is my idea close at all to how strcmp works? and where could I get a book or reference to how each of the various C functions like strcmp work and their function definitions? I think learning these would open up alot about C to me.
That's pretty much how strcmp works, although it doesn't just return a boolean, it returns the number of characters by which the two string differ. Therefore when two strings match exactly, strcmp returns 0.
Since fgets leaves the newline on the input, we check to see if it exists.. if it does, we trim it off, if not, we know that there is still some input left in the input buffer, so we slurp it out into a dummy variable and poof, we're set.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.