大家好,我一直是做Java的,所以对VC/C++不熟悉,想请教一下VC/C++中没有现成的String类型吗?难道都要每个项目去自己实现吗?大家现在用的是什么样的String呢?欢迎大家踊跃发言,关于VC/C++的String类型,都可以说,都有分数:)
解决方案 »
- 下面程序怎么改能编译过???
- 为什么我不能定义Cstring呢?求教高手。
- 是不是只能用CComEnumOnSTL实现IEnumVARIANT接口,那我要枚举的元素是对象怎么办?
- 在SERVER端限制最大连接200,那么超过200的话,怎么处理比较好? 拒绝?
- 求教一个SQL的删除语句
- 弹出的对话框不能接受输入,必须先切换到其他程序,再切换回来才能输入,这是为什么?
- 有熟悉SHELL编程的吗?
- 我用CreateWindow建立窗口,但收不到关闭窗口消息
- 在LISTCTRL列表右键删除一行的函数怎么写?
- 关于TreeView
- CRichEditView 中,怎么禁止文件拖放?[50分]
- 求助远程桌面,求购远程桌面代码和技术
CString s1; // Empty string
CString s2( "cat" ); // From a C string literal
CString s3 = s2; // Copy constructor
CString s4( s2 + " " + s3 ); // From a string expressionCString s5( 'x' ); // s5 = "x"
CString s6( 'x', 6 ); // s6 = "xxxxxx"CString s7((LPCSTR)ID_FILE_NEW); // s7 = "Create a new document"CString city = "Philadelphia"; // NOT the assignment operator
Construction
The String as an Array
Assignment/Concatenation
Comparison
Extraction
Other Conversions
Searching
Archive/Dump
Buffer Access
Windows-SpecificConstruction CString Constructs CString objects in various ways.
The String as an Array GetLength Returns the number of characters in a CString object. For multibyte characters, counts each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two characters.
IsEmpty Tests whether a CString object contains no characters.
Empty Forces a string to have 0 length.
GetAt Returns the character at a given position.
operator [] Returns the character at a given position — operator substitution for GetAt.
SetAt Sets a character at a given position.
operator LPCTSTR Directly accesses characters stored in a CString object as a C-style string.
Assignment/Concatenation operator = Assigns a new value to a CString object.
operator + Concatenates two strings and returns a new string.
operator += Concatenates a new string to the end of an existing string.
Comparison operator == <, etc. Comparison operators (case sensitive).
Compare Compares two strings (case sensitive).
CompareNoCase Compares two strings (case insensitive).
Collate Compares two strings (case sensitive, uses locale-specific information).
CollateNoCase Compares two strings (case insensitive, uses locale-specific information).
Extraction Mid Extracts the middle part of a string (like the Basic MID$ function).
Left Extracts the left part of a string (like the Basic LEFT$ function).
Right Extracts the right part of a string (like the Basic RIGHT$ function).
SpanIncluding Extracts a substring that contains only the characters in a set.
SpanExcluding Extracts a substring that contains only the characters not in a set.
Other Conversions MakeUpper Converts all the characters in this string to uppercase characters.
MakeLower Converts all the characters in this string to lowercase characters.
MakeReverse Reverses the characters in this string.
Replace Replaces indicated characters with other characters.
Remove Removes indicated characters from a string.
Insert Inserts a single character or a substring at the given index within the string.
Delete Deletes a character or characters from a string.
Format Format the string as sprintf does.
FormatV Formats the string as vsprintf does.
TrimLeft Trim leading whitespace characters from the string.
TrimRight Trim trailing whitespace characters from the string.
FormatMessage Formats a message string.
Searching Find Finds a character or substring inside a larger string.
ReverseFind Finds a character inside a larger string; starts from the end.
FindOneOf Finds the first matching character from a set.
Archive/Dump operator << Inserts a CString object to an archive or dump context.
operator >> Extracts a CString object from an archive.
Buffer Access GetBuffer Returns a pointer to the characters in the CString.
GetBufferSetLength Returns a pointer to the characters in the CString, truncating to the specified length.
ReleaseBuffer Releases control of the buffer returned by GetBuffer.
FreeExtra Removes any overhead of this string object by freeing any extra memory previously allocated to the string.
LockBuffer Disables reference counting and protects the string in the buffer.
UnlockBuffer Enables reference counting and releases the string in the buffer.
Windows-Specific AllocSysString Allocates a BSTR from CString data.
SetSysString Sets an existing BSTR object with data from a CString object.
LoadString Loads an existing CString object from a Windows resource.
AnsiToOem Makes an in-place conversion from the ANSI character set to the OEM character set.
OemToAnsi Makes an in-place conversion from the OEM character set to the ANSI character set.