summaryrefslogtreecommitdiff
path: root/devdocs/c/string%2Fwide%2Fwmemcmp.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/string%2Fwide%2Fwmemcmp.html
new repository
Diffstat (limited to 'devdocs/c/string%2Fwide%2Fwmemcmp.html')
-rw-r--r--devdocs/c/string%2Fwide%2Fwmemcmp.html68
1 files changed, 68 insertions, 0 deletions
diff --git a/devdocs/c/string%2Fwide%2Fwmemcmp.html b/devdocs/c/string%2Fwide%2Fwmemcmp.html
new file mode 100644
index 00000000..656ec979
--- /dev/null
+++ b/devdocs/c/string%2Fwide%2Fwmemcmp.html
@@ -0,0 +1,68 @@
+ <h1 id="firstHeading" class="firstHeading">wmemcmp</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;wchar.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td> <pre data-language="c">int wmemcmp( const wchar_t* lhs, const wchar_t* rhs, size_t count );</pre>
+</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> </td> </tr> </table> <p>Compares the first <code>count</code> wide characters of the wide character (or compatible integer type) arrays pointed to by <code>lhs</code> and <code>rhs</code>. The comparison is done lexicographically.</p>
+<p>The sign of the result is the sign of the difference between the values of the first pair of wide characters that differ in the arrays being compared.</p>
+<p>If <code>count</code> is zero, the function does nothing.</p>
+<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> lhs, rhs </td> <td> - </td> <td> pointers to the wide character arrays to compare </td>
+</tr> <tr class="t-par"> <td> count </td> <td> - </td> <td> number of wide characters to examine </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p>Negative value if the value of the first differing wide character in <code>lhs</code> is less than the value of the corresponding wide character in <code>rhs</code>: <code>lhs</code> precedes <code>rhs</code> in lexicographical order.</p>
+<p><code>​0​</code> if all <code>count</code> wide characters of <code>lhs</code> and <code>rhs</code> are equal.</p>
+<p>Positive value if the value of the first differing wide character in <code>lhs</code> is greater than the value of the corresponding wide character in <code>rhs</code>: <code>rhs</code> precedes <code>lhs</code> in lexicographical order.</p>
+<h3 id="Notes"> Notes</h3> <p>This function is not locale-sensitive and pays no attention to the values of the <code>wchar_t</code> objects it examines: nulls as well as invalid wide characters are compared too.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;locale.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;wchar.h&gt;
+
+void demo(const wchar_t* lhs, const wchar_t* rhs, size_t sz)
+{
+ for (size_t n = 0; n &lt; sz; ++n)
+ putwchar(lhs[n]);
+
+ int rc = wmemcmp(lhs, rhs, sz);
+ if (rc == 0)
+ wprintf(L" compares equal to ");
+ else if(rc &lt; 0)
+ wprintf(L" precedes ");
+ else if(rc &gt; 0)
+ wprintf(L" follows ");
+
+ for (size_t n = 0; n &lt; sz; ++n)
+ putwchar(rhs[n]);
+ wprintf(L" in lexicographical order\n");
+}
+
+int main(void)
+{
+ setlocale(LC_ALL, "en_US.utf8");
+
+ wchar_t a1[] = {L'α',L'β',L'γ'};
+ wchar_t a2[] = {L'α',L'β',L'δ'};
+
+ size_t sz = sizeof a1 / sizeof *a1;
+ demo(a1, a2, sz);
+ demo(a2, a1, sz);
+ demo(a1, a1, sz);
+}</pre></div> <p>Output:</p>
+<div class="text source-text"><pre data-language="c">αβγ precedes αβδ in lexicographical order
+αβδ follows αβγ in lexicographical order
+αβγ compares equal to αβγ in lexicographical order</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C23 standard (ISO/IEC 9899:2023): </li>
+<ul><li> 7.29.4.4.5 The wmemcmp function (p: TBD) </li></ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul><li> 7.29.4.4.5 The wmemcmp function (p: TBD) </li></ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.29.4.4.5 The wmemcmp function (p: 435) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.24.4.4.5 The wmemcmp function (p: 381) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="wcscmp" title="c/string/wide/wcscmp"> <span class="t-lines"><span>wcscmp</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div> </td> <td> compares two wide strings <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="../byte/memcmp" title="c/string/byte/memcmp"> <span class="t-lines"><span>memcmp</span></span></a></div> </td> <td> compares two buffers <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="wcsncmp" title="c/string/wide/wcsncmp"> <span class="t-lines"><span>wcsncmp</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div> </td> <td> compares a certain amount of characters from two wide strings <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/string/wide/wmemcmp" title="cpp/string/wide/wmemcmp">C++ documentation</a></span> for <code>wmemcmp</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/string/wide/wmemcmp" class="_attribution-link">https://en.cppreference.com/w/c/string/wide/wmemcmp</a>
+ </p>
+</div>