![]() However, the LPCTSTR pointer is temporary and becomes invalid when any change is made to CString. You can use CString methods, for example, SetAt, to modify individual characters in the string object. The strcpy function puts a copy of the C-style string in the variable myString. In the following example, the CString returns a pointer to a read-only C-style null-terminated string. To use a CString object as a C-style string, cast the object to LPCTSTR. ![]() Using CString as a C-Style Null-Terminated String Using CString objects with variable argument functions Working with standard run-time library string functions This topic contains the following sections that explain how to use a CString object as if it were a C-style null-terminated string.Ĭonverting to C-style null-terminated strings Instead, CString tracks the length of character data so that it can more securely watch the data and the space it requires.ĬString does accept C-style strings, and provides ways to access character data as a C-style string. ( CString is a typedef that specializes CStringT to work with the kind of character data that CString supports.)ĬString does not store character data internally as a C-style null-terminated string. CString inherits the set of the methods and operators that are defined in the class template CStringT to work with string data. A CString object contains character string data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |