This article summarizes CString left (), Mid (), right () and several CString string lookup related functions to use, first need to find, CString has the following several lookup functions, respectively, find (), Reversefind (), Findoneof ().
One, CString find (), findoneof (), Reversefind ()
All three functions return a value of integer int. 1, find ()
This function starts at the left 0 index, finds the first character position that appears, and returns position. Examples are as follows:
2 |
ASSERT (S.find (' b ') = = 1); |
Return value: If found, returns 1 2, findoneof () , where the start of the 0 index is not found.
Given a string, and then find the first character position that appears, the following example:
2 |
ASSERT (s.findoneof ("ZB") = = 1); |
Return value: If found, returns 1 3, Reversefind () , where the start of the 0 index is not found.
The function reverses the position where the character appears. Examples are as follows:
2 |
ASSERT (S.reversefind (' b ') = = 2); |
Return value: If found, returns the location starting at 0 not found, returns-1 two, CString left (), Mid (), right ()
After the lookup is complete, we may need to intercept the string. The CString has several string intercept functions as follows. 1, left (int ncount)
The function intercepts the left ncount character, and if a double-byte character is encountered (as is also understood by mid and right below), such as Chinese, the garbled text may be truncated. Because the ncount is counted by byte. 2, Mid (int nfirst) and mid (int nfirst, int ncount)
The Mid (int nfirst) function intercepts the string that starts at Nfirst until the end of the string.
The Mid (int nfirst, int ncount) function intercepts the ncount byte characters from the beginning of the Nfirst. 3, right (int ncount)
This function intercepts the right ncount byte character.
The left (), Mid (), right () function examples are as follows: