Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/string/byte/memcmp"

From cppreference.com
< cpp‎ | string‎ | byte
m (r2.7.3) (Robot: Adding fr, ja, pt, zh)
(+see c)
Line 14: Line 14:
  
 
===Return value===
 
===Return value===
 
+
Negative value if {{tt|lhs}} is ''less than'' {{tt|rhs}}.
negative value if {{tt|lhs}} is ''less than'' {{tt|rhs}}.
+
  
 
{{c|0}} if {{tt|lhs}} is ''equal to'' {{tt|rhs}}.
 
{{c|0}} if {{tt|lhs}} is ''equal to'' {{tt|rhs}}.
  
positive value if {{tt|lhs}} is ''greater than'' {{tt|rhs}}.
+
Positive value if {{tt|lhs}} is ''greater than'' {{tt|rhs}}.
  
 
===Example===
 
===Example===
Line 32: Line 31:
 
{{dcl list template | cpp/string/byte/dcl list strcmp}}
 
{{dcl list template | cpp/string/byte/dcl list strcmp}}
 
{{dcl list template | cpp/string/byte/dcl list strncmp}}
 
{{dcl list template | cpp/string/byte/dcl list strncmp}}
 +
{{dcl list see c | c/string/byte/memcmp}}
 
{{dcl list end}}
 
{{dcl list end}}
  

Revision as of 07:48, 14 May 2012

Template:cpp/string/byte/sidebar

Defined in header <cstring>
int memcmp( const void* lhs, const void* rhs, std::size_t count );

Compares the first count characters of the objects pointed to by lhs and rhs. The comparison is done lexicographically.

Contents

Parameters

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

Return value

Negative value if lhs is less than rhs.

0 if lhs is equal to rhs.

Positive value if lhs is greater than rhs.

Example

See also

Template:cpp/string/byte/dcl list strcmpTemplate:cpp/string/byte/dcl list strncmp
C documentation for memcmp