By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,562 Members | 1,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,562 IT Pros & Developers. It's quick & easy.

diff between memcmp and strcmp

P: 1
can anybody tell me what is difference between memcmp and strcmp

which one is better
efficient
and when to use memcmp or strcmp
Aug 4 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
They both compare char for char, however memcmp takes the number of characters to compare, strcmp assumes the pointers passed to it are pointers to strings which zero terminators.

Generally use strcmp when comparing strings, this makes it clear what you are doing, use memcmp when you are comparing anything other than strings.

I would imagine that there was not much difference in efficiency but I might be wrong.
Aug 4 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.