常用的字符串操作

// Format string
_vsntprintf_s/_vstprintf_s: Write formatted output using a pointer to a  list of arguments.
_sntprintf_s/_stprintf_s: Writes formatted data to a string.
_sntscanf_s/_stscanf_s: Reads formatted data of a specified length from a  string.

 

// Find string
_tcschr: Finds the first occurrence of c in  str.
_tcsrchr: Scan a string for the last occurrence  of a character.
_tcsstr: Return a pointer to the first occurrence  of a search string in a string.
_tcsspn: Returns the index of the first character in a string that does  not belong to a set of characters.
_tcsspnp_s: Returns a pointer to the first character in a given string that is not in another given string.
memchr: Finds characters in a buffer.

 

// Reverse
_tcsrev: Reverse characters of a string.

 

// string to digit
_tcstol: Convert strings to a long-integer value.
_tcstoul: Convert strings to an unsigned long-integer value.
_tcstod: Convert strings to a double-precision value.

 

// uppercase/lowercase
_tcsupr_s: Convert a string to uppercase.
_tcslwr_s: Convert a string to lowercase.


// Comparison
_tcsnicmp: Compares n bytes of two strings, ignoring case.
_tcsicmp: Perform a lowercase comparison of strings.
_tcscmp: Compare strings.
memcmp: Compare characters in two buffers.


// Copy
_tcsncpy_s: Copies n bytes of a string to a destination string.
_tcscpy_s(strcpy_s/_mbscpy_s/wcscpy_s): Copy a string.

// Appending
_tcscat/_tcsncat_s: Append characters to a string.

// Length
_tcslen(strlen/wcslen): strlen interprets  the string as a single-byte character string, so its return value is  always equal to the number of bytes, even if the string contains  multibyte characters. wcslen is a  wide-character version of strlen;

_tcsclen(_mbslen/wcslen): _mbslen,_mbslen_l, _mbstrlen and _mbstrlen_l return  the number of multibyte characters in a multibyte-character string but  they do not test for multibyte-character validity.

_tcsclen_l: _mbstrlen and _mbstrlen_l tests for multibyte-character  validity and recognizes multibyte-character sequencessetlocale,  _wsetlocale. If the string passed to _mbstrlen or_mbstrlen_l contain an  invalid multibyte character for the code page, it returns -1 and sets  errno to EILSEQ.

 

你可能感兴趣的:(C++,C++)