wcsncmp

strcmp, wcscmp,strncmp, wcsncmp一樣都是比較字元指針函式原型,屬於Windows api函式。

int wcsncmp( const wchar_t *string1, const wchar_t *string2, size_t count );

基本介紹

  • 中文名:wcsncmp
  • 外文名:wcsncmp
函式簡介,參數,返回值,範例,

函式簡介

int wcsncmp( const wchar_t *string1, const wchar_t *string2, size_t count );
比較兩個寬字元串 count指定個數的字元,使用當前區域設定或指定的區域設定。

參數

string1string2 為以零值結尾的寬字元串
count 要比較的字元數。

返回值

< 0
string1 小於string2
0
string1 和 string2 相等
>0
string1 大於string2
頭檔案
Routine 常規
Required header 頭檔案
strncmp
<string.h>
wcsncmp
<string.h> or <wchar.h>
_mbsncmp,_mbsncmp_l
<mbstring.h>

範例

//    demo#include <string.h>#include <stdio.h>int main( void ){    wchar_t tmp[20];      int result;    wchar_t string1[] = "The quick brown dog jumps over the lazy fox";     wchar_t string2[] = "The QUICK brown fox jumps over the lazy dog";    result = wcsncmp( string1, string2 , 10 );    if( result > 0 )        wcscpy_s( tmp, sizeof(tmp), "greater than" );    else if( result < 0 )        wcscpy_s( tmp, sizeof(tmp), "less than" );     else        wcscpy_s( tmp, sizeof(tmp), "equal to" );    wprintf( "Result:      String 1 is %s string 2\n\n", tmp );}

相關詞條

熱門詞條

聯絡我們