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

要用CString如何构建?不想通过传统的char字符实现数组另外,请介绍CStringArray详细用法,我手头没MSDN,非常急!... 要用CString如何构建?不想通过传统的char字符实现数组
另外,请介绍CStringArray详细用法,我手头没MSDN,非常急!
展开
 我来答
百度网友2de7f4646
2006-01-25 · TA获得超过523个赞
知道小有建树答主
回答量:733
采纳率:0%
帮助的人:426万
展开全部
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 access to elements in the array. Can be NULL.
SetAt Sets the value for a given index; array not allowed to grow.

Growing the Array

Add Adds an element to the end of the array; grows the array if necessary.
Append Appends another array to the array; grows the array if necessary.
Copy Copies anolther array to the array; grows the array if necessary.
SetAtGrow Sets the value for a given index; grows the array if necessary.

Insertion/Removal

InsertAt Inserts an element (or all the elements in another array) at a specified index.
IsEmpty Determines if the array is empty
RemoveAt Removes an element at a specific index.

Operators

operator [] Sets or gets the element at the specified index.

See Also
CStringArray Overview | Hierarchy Chart

--------------------------------------------------------------------------------

Send feedback on this topic to Microsoft

© Microsoft Corporation. All rights reserved.
sangermax
2006-01-25 · TA获得超过203个赞
知道小有建树答主
回答量:235
采纳率:0%
帮助的人:211万
展开全部
CString cs;
cs.GetAt(i);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式