Export (0) Print
Expand All

StrCmpNIC function

Compares a specified number of characters from the beginning of two strings using C run-time (ASCII) collation rules. The comparison is not case-sensitive.

Syntax


int StrCmpNIC(
  _In_  LPCTSTR pszStr1,
  _In_  LPCTSTR pszStr2,
  int nChar
);

Parameters

pszStr1 [in]

Type: LPCTSTR

A pointer to the first null-terminated string to be compared.

pszStr2 [in]

Type: LPCTSTR

A pointer to the second null-terminated string to be compared.

nChar

Type: int

The number of characters from the beginning of each string to be compared.

Return value

Type: int

Returns zero if the substrings are identical. Returns a positive value if the string taken from that pointed to by pszStr1 is alphabetically greater the string taken from that pointed to by pszStr2. Returns a negative value if the string taken from that pointed to by pszStr1 is alphabetically less than the string taken from that pointed to by pszStr2.

Remarks

Note that StrCmpNIC was designed for comparing canonical strings. These strings are not localized and consist only of characters below ASCII value 128. Therefore, it will not function correctly with a double-byte character set (DBCS) or other multiple-character data.

This function locates the first unequal characters and returns a positive number if the character from the first string is greater than the character from the second, a negative number if it is less, or zero if they are equal. For example, suppose that pszStr1="abczb", pszStr2="abcdefg", and you are comparing the first four characters from each. StrCmpNIC determines that the first unequal character is at position four ("z" in pszStr1 and "d" in pszStr2) and returns a positive value since the ASCII code for "z" is greater than the ASCII code for "d".

For those versions of Windows that do not include StrCmpNIC in Shlwapi.h, this function's individual ANSI or Unicode version must be called directly from Shlwapi.dll. StrCmpNICA is ordinal 153 and StrCmpNICW is ordinal 154.

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 5.0 or later)

Unicode and ANSI names

StrCmpNICW (Unicode) and StrCmpNICA (ANSI)

See also

CompareString
StrCmpIC
StrCmpNI

 

 

Community Additions

ADD
Show:
© 2014 Microsoft