Namespaces
Variants
Views
Actions

std::char_traits::compare

From cppreference.com
< cpp‎ | string‎ | char traits
Revision as of 23:43, 24 February 2013 by 2hertz (Talk | contribs)

Template:ddcl list begin <tr class="t-dcl ">

<td class="t-dcl-nopad">
static int compare( const char_type* s1, const char_type* s2, std::size_t n );
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

Compares the first n characters of the character strings s1 and s2. The comparison is done lexicographically.

Contents

Parameters

s1, s2 - pointers to character strings to compare
n - the number of characters to compare from each character string

Return value

Negative value if s1 is less than s2.

0 if s1 is equal to s2.

Positive value if s1 is greater than s2.

Exceptions

(none)

Complexity

Linear.