wcsncmp - C wchar.h

C examples for wchar.h:wcsncmp

Summary

ItemValue
typefunction

From


<cwchar>
<wchar.h>

Description

Compare characters of two wide strings

Prototype

int wcsncmp (const wchar_t* wcs1, const wchar_t* wcs2, size_t num);

Parameters

Parameter Description
wcs1 C wide string to be compared.
wcs2 C wide string to be compared.
num Maximum number of characters to compare.

Return Value

0 indicates that the characters in both strings are equal.

>0 indicates that wcs1 is greater than wcs2.

<0 indicates that wcs1 is less than wcs2.

Demo Code


#include <stdio.h>
#include <string.h>

int main ()/*from w ww.ja  va2  s. co m*/
{
  wchar_t wcs[][5] = { L"123" , L"qqq" , L"Rest" };
  int n;
  for (n=0 ; n<3 ; n++)
    if (wcsncmp (wcs[n],L"qq",2) == 0)
    {
      wprintf (L"found %ls\n",wcs[n]);
    }
  return 0;
}

Related Tutorials