Namespaces
Variants
Views
Actions

std::memcmp

From cppreference.com
< cpp‎ | string‎ | byte
 
 
 
 
Defined in header <cstring>
int memcmp( const void* lhs, const void* rhs, std::size_t count );

Reinterprets the objects pointed to by lhs and rhs as arrays of unsigned char and compares the first count bytes of these arrays. The comparison is done lexicographically.

The sign of the result is the sign of the difference between the values of the first pair of bytes (both interpreted as unsigned char) that differ in the objects being compared.

Contents

[edit] Parameters

lhs, rhs - pointers to the memory buffers to compare
count - number of bytes to examine

[edit] Return value

Negative value if the first differing byte (reinterpreted as unsigned char) in lhs is less than the corresponding byte in rhs.

0 if all count bytes of lhs and rhs are equal.

Positive value if the first differing byte in lhs is greater than the corresponding byte in rhs.

[edit] Notes

This function reads