VC++中如何实现字符串数组?

来源:百度知道 编辑:UC知道 时间:2024/05/16 16:26:14
要用CString如何构建?不想通过传统的char字符实现数组
另外,请介绍CStringArray详细用法,我手头没MSDN,非常急!

CString类:
用GetString(数组只读时用)和GetBuffer(向数组写数据时用,GetBuffer无参数)来获得CString内保存的数组,

当GetBuffer有参数时(int型)为分配指定大小的数组(但用GetLength好象不能获得字符串的长度).

下面是把CStringArray的函数说明复制下来的(原文,英文我看不明白,你自己看吧).
Base Class Members

CObject Members

CStringArray Members

Construction

CStringArray Constructs an empty array for CString objects.

Bounds

GetCount Gets number of elements in this array.
GetSize Gets number of elements in this array.
GetUpperBound Returns the largest valid index.
SetSize Sets the number of elements to be contained in this array.

Operations

FreeExtra Frees all unused memory above the current upper bound.
RemoveAll Removes all the elements from this array.

Element Access

ElementAt Returns a temporary reference to the element pointer within the array.
GetAt Returns the value at a given index.
GetData Allows acce