For memecmp(), the third parameter is size_t(unsigned). But when we pass third parameter as -1 returns always 0, eventhough the memory block pointed by first and second parameters are different?
Asked
Active
Viewed 106 times
-4
-
There is no question here – Scott Aug 19 '15 at 08:10
-
I am sorry, I do not have the answer because the question is not clear enough to be answered. – Itban Saeed Aug 19 '15 at 08:15
-
That's not even a question. Did you know that a question typically has a question mark? ... See? Just like that. – JK. Aug 25 '15 at 05:39
-
@JK thanks for pointing as i am new here so don't know this things. – geek Aug 27 '15 at 07:55
1 Answers
0
What are you comparing? memcmp()
returns 0
if the contents in the two memory blocks are equal.

M. Shaw
- 1,742
- 11
- 15
-
In memcmp(), third parameter tells the size(size_t) of the memory blocks to be compared between 1 and 2. But if we pass the third parameter as -1 which is a negative value. And as the third parameter is -1 which wraps its value to max value. In case of 32 bit system the value will become as 0xffffffff. But in my case the value which memcmp() return is zero. So can you please explain me how this is happening also please let me know if there is any documented reference which justify the same – geek Aug 21 '15 at 09:14
-
@user3782944 As I said, `memcmp(a, b, num)` returns `0` if the memory block pointed by `a` and `b` are equal. – M. Shaw Aug 21 '15 at 09:33
-