wcscmp - C wchar.h

C examples for wchar.h:wcscmp

Type

function

From


<cwchar>
<wchar.h>

Description

Compare two strings

Prototype

int wcscmp (const wchar_t* wcs1, const wchar_t* wcs2);

Parameters

Parameter Description
wcs1 C wide string to be compared.
wcs2 C wide string to be compared.

Return Value

Value Meaning
0 equal
>0 wcs1 is greater than wcs2
<0 wcs1 is less than wcs2

Demo Code


#include <stdio.h>
#include <wchar.h>

int main ()/*from   w  ww . j av a  2  s.c o m*/
{
  wchar_t wsKey[] = L"apple\n";
  wchar_t wsInput[80];
  do {

     wprintf (L"Guess my favourite fruit(apple)? ");

     fgetws (wsInput,80,stdin);

  } while (wcscmp (wsKey,wsInput) != 0);

  fputws (L"Correct answer!",stdout);

  return 0;
}

Related Tutorials