It compares the first count characters of the arrays pointed to by buf1 and buf2.
int memcmp(const void *buf1, const void *buf2, size_t count); Return Value: it returns an integer. Parameters: buf1 : Pointer to block of memory. buf2 : Pointer to block of memory. count : Maximum numbers of bytes to compare. Return Value is interpreted as : Value Meaning Less than zero buf1 is less than buf2. Zero buf1 is equal to buf2. Greater than zero buf1 is greater than buf2.
Example 1. When count Greater than zero( > 0)
Welcome to GeeksforGeeks is greater than Hello Geeks
Example 2. When count less than zero( < 0)
String 1 is less than String 2
Example 3 : When count equal to zero ( = 0)
Welcome to GeeksforGeeks is the same as Welcome to GeeksforGeeks
This article is contributed by Shivani Ghughtyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Difference between Virtual function and Pure virtual function in C++
- cin get() in C++ with Examples
- Difference between Increment and Decrement Operators
- Map of Vectors in C++ STL with Examples
- Problem in comparing Floating point numbers and how to compare them correctly?
- exit(0) vs exit(1) in C/C++ with Examples
- C++ program to print all Even and Odd numbers from 1 to N
- Reverse the content of a file and store it in another
- Minimum cells to be flipped to get a 2*2 submatrix with equal elements
- Nested Loops in C++ with Examples
- _Find_first() function in C++ bitset with Examples
- _Find_next() function in C++ bitset with Examples
- Left-Right traversal of all the levels of N-ary tree
- Difference between Iterators and Pointers in C/C++ with Examples
- ostream::seekp(pos) method in C++ with Exmaples