# wcsncmp

### Function

> wcsncmp

### Syntax

> wcsncmp( WStr1, WStr2, Num );

### Parameters

**\[WStr1]**

A [MASM-like expression](https://docs.hyperdbg.org/commands/scripting-language/assumptions-and-evaluations) or a wide-character string to compare with **WStr2**.

**\[WStr2]**

A [MASM-like expression](https://docs.hyperdbg.org/commands/scripting-language/assumptions-and-evaluations) or a wide-character string to compare with **WStr1**.

**\[Num]**

Maximum number of characters to compare.

### Description

Compares up to ***Num*** characters of the wide-character string ***WStr1*** to the wide-character string ***WStr2***.

If the characters are equal, the comparison continues with the next pair of characters. This process repeats until the characters differ, a terminating null character is encountered, or ***Num*** characters have been compared in both strings, whichever occurs first.

{% hint style="info" %}
Wide-character strings are started with an **L** character before the quotations. For example **L"This is a wide-character string"**.
{% endhint %}

### Return value

Returns an integer value indicating the relationship between the strings:<br>

| Return Value | Indicates                                                                                    |
| ------------ | -------------------------------------------------------------------------------------------- |
| <0           | The first wide-character that does not match has a lower value in *WStr1* than in *WStr2.*   |
| 0            | The contents of both wide-character strings are equal.                                       |
| >0           | The first wide-character that does not match has a greater value in *WStr1* than in *WStr2.* |

### Examples

``wcsncmp(fffff806`6de00000, @rax+c0, 0n12);``

Compare the the first 12 (decimal) characters of  the wide-character string located at ``fffff806`6de00000`` with the wide-character string located at `@rax+c0`.

`wcsncmp(@rcx, L"Test WString", 12);`

Compare the first 0x12 (hexadecimal) characters of the wide-character string located at `@rcx` with the wide-character string `L"Test WString"`.

`wcsncmp(L"Test WString1", L"Test WString2", 0n10);`

Compare the first 10 (decimal) characters of the wide-character string `L"Test WString1"` with the wide-character string `L"Test WString2"`.

### Remarks

This function checks for the validity of both the source and the destination address before the comparison.&#x20;

The support for this function is added from **v0.9**.

### Related

[strcmp](https://docs.hyperdbg.org/commands/scripting-language/functions/strings/strcmp)

[strncmp](https://docs.hyperdbg.org/commands/scripting-language/functions/strings/strncmp)

[memcmp](https://docs.hyperdbg.org/commands/scripting-language/functions/memory/memcmp)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hyperdbg.org/commands/scripting-language/functions/strings/wcsncmp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
