![]() |
C - Entwicklung Bibliotheks-Funktionen: 2 Strings Readonly Homepage von PS-Trainer - C-Entwicklung - Strings - an PS-Trainer |
|
| Strings & characters | Overview |
| strncmp, wcsncmp, _mbsncmp | Compare characters of two strings. |
| _stricmp, _wcsicmp, _mbsicmp | Perform a lowercase comparison of strings. |
| _strnicmp, _wcsnicmp, _mbsnicmp | Compare characters of two strings without regard to case. |
| strcmp, wcscmp, _mbscmp | Compare strings. |
| _stricmp, _wcsicmp,
_mbsicmp Perform a lowercase comparison of strings. int _stricmp( const char *string1, const char *string2 ); int _wcsicmp( const wchar_t *string1, const wchar_t *string2 ); int _mbsicmp( const unsigned char *string1, const unsigned char_t *string2 );
Remarks The _stricmp function lexicographically compares lowercase versions of string1 and string2 and returns a value indicating their relationship. _stricmp differs from _stricoll in that the _stricmp comparison is not affected by locale, whereas the _stricoll comparison is according to the LC_COLLATE category of the current locale. For more information on the LC_COLLATE category, see setlocale. The _strcmpi function is equivalent to _stricmp and is provided for backward compatibility only. _wcsicmp and _mbsicmp are wide-character and multibyte-character versions of _stricmp. The arguments and return value of _wcsicmp are wide-character strings; those of _mbsicmp are multibyte-character strings. _mbsicmp recognizes multibyte-character sequences according to the current multibyte code page and returns _NLSCMPERROR on an error. (For more information, see Code Pages.) These three functions behave identically otherwise. _wcsicmp and wcscmp behave identically except that wcscmp does not convert its arguments to lowercase before comparing them. _mbsicmp and _mbscmp behave identically except that _mbscmp does not convert its arguments to lowercase before comparing them. Generic-Text Routine Mappings
Subject: String Manipulation Routines Keywords: See Also memcmp, _memicmp, strcmp, strcoll Functions, strncmp, _strnicmp, strrchr, _strset, strspn |
||||||||||||||||||||||||
| Return Value The (integer) return value indicates the relation of string1 to string2 as follows. Return Value Description
Parameters
|
||||||||||||||||||||||||
|
Example #include <string.h> char string1[] = "The
quick brown dog jumps over the lazy fox"; void main( void ) strcmp: String
1 is greater than string 2 |
| _strnicmp, _wcsnicmp,
_mbsnicmp Compare characters of two strings without regard to case. int _strnicmp( const char *string1, const char *string2, size_t count ); int _wcsnicmp( const wchar_t *string1, const wchar_t *string2, size_t count ); int _mbsnicmp( const unsigned char *string1, const unsigned char *string2, size_t count );
Remarks The _strnicmp function lexicographically compares, at most, the first count characters of string1 and string2. The comparison is performed without regard to case; _strnicmp is a case-insensitive version of strncmp. The comparison ends if a terminating null character is reached in either string before count characters are compared. If the strings are equal when a terminating null character is reached in either string before count characters are compared, the shorter string is lesser. Two strings containing characters located between 'Z' and 'a' in the ASCII table ('[', '\', ']', '^', '_', and '`') compare differently, depending on their case. For example, the two strings "ABCDE" and "ABCD^" compare one way if the comparison is lowercase ("abcde" > "abcd^") and the other way ("ABCDE" < "ABCD^") if it is uppercase. _wcsnicmp and _mbsnicmp are wide-character and multibyte-character versions of _strnicmp. The arguments and return value of _wcsnicmp are wide-character strings; those of _mbsnicmp are multibyte-character strings. _mbsnicmp recognizes multibyte-character sequences according to the current multibyte code page and returns _NLSCMPERROR on an error. For more information, see Code Pages. These three functions behave identically otherwise. These functions are not affected by the current locale setting. Generic-Text Routine Mappings
Subject: String Manipulation Routines Keywords: See Also strcat, strcmp, strcpy, strncat, strncmp, strncpy, strrchr, _strset, strspn |
||||||||||||||||||||||||||||
| Return Value The (integer) return value indicates the relationship between the substrings as follows. Return Value Description
Parameters
|
||||||||||||||||||||||||||||
|
Example char string1[] = "The
quick brown dog jumps over the lazy fox"; void main( void ) Function: strncmp
(first 10 characters only) Function: _strnicmp
(first 10 characters only) |
| strncmp, wcsncmp,
_mbsncmp Compare characters of two strings. int strncmp( const char *string1, const char *string2, size_t count ); int wcsncmp( const wchar_t *string1, const wchar_t *string2, size_t count ); int _mbsncmp( const unsigned char *string1, const unsigned char string2, size_t count );
Remarks The strncmp function lexicographically compares, at most, the first count characters in string1 and string2 and returns a value indicating the relationship between the substrings. strncmp is a case-sensitive version of _strnicmp. Unlike strcoll, strncmp is not affected by locale. For more information on the LC_COLLATE category, see setlocale. wcsncmp and _mbsncmp are wide-character and multibyte-character versions of strncmp. The arguments and return value of wcsncmp are wide-character strings; those of _mbsncmp are multibyte-character strings. _mbsncmp recognizes multibyte-character sequences according to the current multibyte code page and returns _NLSCMPERROR on an error. For more information, see Code Pages. These three functions behave identically otherwise. wcsncmp and _mbsncmp are case-sensitive versions of _wcsnicmp and _mbsnicmp. Generic-Text Routine Mappings
Subject: String Manipulation Routines Keywords: See Also _mbsnbcmp, _mbsnbicmp, strcmp, strcoll Functions, _strnicmp, strrchr, _strset, strspn |
||||||||||||||||||||||||||||
| Return Value The (integer) return value indicates the relation of the substrings of string1 and string2 as follows. Return Value Description
Parameters
|
||||||||||||||||||||||||||||
|
Example char string1[] = "The
quick brown dog jumps over the lazy fox"; void main( void ) Function: strncmp
(first 10 characters only) Function: _strnicmp
(first 10 characters only) |
| strcmp, wcscmp,
_mbscmp Compare strings. int strcmp( const char *string1, const char *string2 ); int wcscmp( const wchar_t *string1, const wchar_t *string2 ); int _mbscmp(const unsigned char *string1, const unsigned char *string2 );
Remarks The strcmp function compares string1 and string2 lexicographically and returns a value indicating their relationship. wcscmp and _mbscmp are wide-character and multibyte-character versions of strcmp. The arguments and return value of wcscmp are wide-character strings; those of _mbscmp are multibyte-character strings. _mbscmp recognizes multibyte-character sequences according to the current multibyte code page and returns _NLSCMPERROR on an error. (For more information, see Code Pages.) These three functions behave identically otherwise. Generic-Text Routine Mappings
The strcmp functions differ from the strcoll functions in that strcmp comparisons are not affected by locale, whereas the manner of strcoll comparisons is determined by the LC_COLLATE category of the current locale. For more information on the LC_COLLATE category, see setlocale. In the "C" locale, the order of characters in the character set (ASCII character set) is the same as the lexicographic character order. However, in other locales, the order of characters in the character set may differ from the lexicographic order. For example, in certain European locales, the character 'a' (value 0x61) precedes the character 'ä' (value 0xE4) in the character set, but the character 'ä' precedes the character 'a' lexicographically. In locales for which the character set and the lexicographic character order differ, use strcoll rather than strcmp for lexicographic comparison of strings according to the LC_COLLATE category setting of the current locale. Thus, to perform a lexicographic comparison of the locale in the above example, use strcoll rather than strcmp. Alternatively, you can use strxfrm on the original strings, then use strcmp on the resulting strings. _stricmp, _wcsicmp, and _mbsicmp compare strings by first converting them to their lowercase forms.Two strings containing characters located between 'Z' and 'a' in the ASCII table ('[', '\', ']', '^', '_', and '`') compare differently, depending on their case. For example, the two strings "ABCDE" and "ABCD^" compare one way if the comparison is lowercase ("abcde" > "abcd^") and the other way ("ABCDE" < "ABCD^") if the comparison is uppercase. Subject: String Manipulation Routines Keywords: See Also memcmp, _memicmp, strcoll Functions, _stricmp, strncmp, _strnicmp, strrchr, strspn, strxfrm |
||||||||||||||||||||||||
| Return Value The (integer) return value for each of these functions indicates the lexicographic relation of string1 to string2. Value Relationship of string1 to string2
Parameters
|
||||||||||||||||||||||||
|
Example #include <string.h> char string1[] = "The
quick brown dog jumps over the lazy fox"; void main( void ) strcmp: String
1 is greater than string 2 |
| Aktuelle Daten dieser Seite | Letzte Änderung: |
| |