![]() |
C - Entwicklung Bibliotheks-Funktionen: 2 Strings RW Homepage von PS-Trainer - C-Entwicklung - Strings - an PS-Trainer |
|
| Strings & characters | Overview |
| strncpy, wcsncpy, _mbsncpy | Copy characters of one string to another. |
| strcpy, wcscpy, _mbscpy | Copy a string. |
| _strdup, _wcsdup, _mbsdup | Duplicate strings. |
| strncat,
wcsncat, _mbsncat |
Append characters of a string. |
| strcat,
wcscat, _mbscat |
Append a string. |
| strncat, wcsncat,
_mbsncat Append characters of a string. char *strncat( char *strDest, const char *strSource, size_t count ); wchar_t *wcsncat( wchar_t *strDest, const wchar_t *strSource, size_t count ); unsigned char *_mbsncat( unsigned char *strDest, const unsigned char *strSource, size_t count);
Remarks The strncat function appends, at most, the first count characters of strSource to strDest. The initial character of strSource overwrites the terminating null character of strDest. If a null character appears in strSource before count characters are appended, strncat appends all characters from strSource, up to the null character. If count is greater than the length of strSource, the length of strSource is used in place of count. The resulting string is terminated with a null character. If copying takes place between strings that overlap, the behavior is undefined. wcsncat and _mbsncat are wide-character and multibyte-character versions of strncat. The string arguments and return value of wcsncat are wide-character strings; those of _mbsncat are multibyte-character strings. These three functions behave identically otherwise. Generic-Text Routine Mappings
Subject: String Manipulation Routines Keywords: See Also _mbsnbcat, strcat, strcmp, strcpy, strncmp, strncpy, _strnicmp, strrchr, _strset, strspn |
||||||||||||||||||||||||
| Return Value Each of these functions returns a pointer to the destination string. No return value is reserved to indicate an error. Parameters
|
||||||||||||||||||||||||
|
Example #include <string.h> void main( void ) |
| strcat, wcscat,
_mbscat Append a string. char *strcat( char *strDestination, const char *strSource ); wchar_t *wcscat( wchar_t *strDestination, const wchar_t *strSource ); unsigned char *_mbscat( unsigned char *strDestination, const unsigned char *strSource );
Remarks The strcat function appends strSource to strDestination and terminates the resulting string with a null character. The initial character of strSource overwrites the terminating null character of strDestination. No overflow checking is performed when strings are copied or appended. The behavior of strcat is undefined if the source and destination strings overlap. wcscat and _mbscat are wide-character and multibyte-character versions of strcat. The arguments and return value of wcscat are wide-character strings; those of _mbscat are multibyte-character strings. These three functions behave identically otherwise. Generic-Text Routine Mappings
Subject: String Manipulation Routines Keywords: See Also strncat, strncmp, strncpy, _strnicmp, strrchr, strspn |
||||||||||||||||||||||||
| Return Value Each of these functions returns the destination string (strDestination). No return value is reserved to indicate an error. Parameters
|
||||||||||||||||||||||||
|
Example #include <string.h> void main( void ) |
| strncpy, wcsncpy,
_mbsncpy Copy characters of one string to another. char *strncpy( char *strDest, const char *strSource, size_t count ); wchar_t *wcsncpy( wchar_t *strDest, const wchar_t *strSource, size_t count ); unsigned char *_mbsncpy( unsigned char *strDest, const unsigned char *strSource, size_t count );
Remarks The strncpy function copies the initial count characters of strSource to strDest and returns strDest. If count is less than or equal to the length of strSource, a null character is not appended automatically to the copied string. If count is greater than the length of strSource, the destination string is padded with null characters up to length count. The behavior of strncpy is undefined if the source and destination strings overlap. wcsncpy and _mbsncpy are wide-character and multibyte-character versions of strncpy. The arguments and return value of wcsncpy and _mbsncpy vary accordingly. These three functions behave identically otherwise. Generic-Text Routine Mappings
Subject: String Manipulation Routines Keywords: See Also _mbsnbcpy, strcat, strcmp, strcpy, strncat, strncmp, _strnicmp, strrchr, _strset, strspn |
||||||||||||||||||||||||
| Return Value Each of these functions returns the string strDest. No return value is reserved to indicate an error. Parameters
|
||||||||||||||||||||||||
|
Example #include <string.h> void main( void ) |
| strcpy, wcscpy,
_mbscpy Copy a string. char *strcpy( char *strDestination, const char *strSource ); wchar_t *wcscpy( wchar_t *strDestination, const wchar_t *strSource ); unsigned char *_mbscpy( unsigned char *strDestination, const unsigned char *strSource );
Remarks The strcpy function copies strSource, including the terminating null character, to the location specified by strDestination. No overflow checking is performed when strings are copied or appended. The behavior of strcpy is undefined if the source and destination strings overlap. wcscpy and _mbscpy are wide-character and multibyte-character versions of strcpy. The arguments and return value of wcscpy are wide-character strings; those of _mbscpy are multibyte-character strings. These three functions behave identically otherwise. Generic-Text Routine Mappings
Subject: String Manipulation Routines Keywords: See Also strcat, strcmp, strncat, strncmp, strncpy, _strnicmp, strrchr, strspn |
||||||||||||||||||||||||
| Return Value Each of these functions returns the destination string. No return value is reserved to indicate an error. Parameters
|
||||||||||||||||||||||||
|
Example #include <string.h> void main( void ) |
| _strdup, _wcsdup,
_mbsdup Duplicate strings. char *_strdup( const char *strSource ); wchar_t *_wcsdup( const wchar_t *strSource ); unsigned char *_mbsdup( const unsigned char *strSource );
Remarks The _strdup function calls malloc to allocate storage space for a copy of strSource and then copies strSource to the allocated space. _wcsdup and _mbsdup are wide-character and multibyte-character versions of _strdup. The arguments and return value of _wcsdup are wide-character strings; those of _mbsdup are multibyte-character strings. These three functions behave identically otherwise. Generic-Text Routine Mappings
Because _strdup calls malloc to allocate storage space for the copy of strSource, it is good practice always to release this memory by calling the free routine on the pointer returned by the call to _strdup. Subject: String Manipulation Routines Keywords: See Also memset, strcat, strcmp, strncat, strncmp, strncpy, _strnicmp, strrchr, strspn |
||||||||||||||||||||||||
| Return Value Each of these functions returns a pointer to the storage location for the copied string or NULL if storage cannot be allocated. Parameter
|
||||||||||||||||||||||||
|
Example #include <string.h> void main( void ) |
| Aktuelle Daten dieser Seite | Letzte Änderung: |
| |