VC++中如何为字符数组追加内容
答案:2 悬赏:50 手机版
解决时间 2021-02-09 22:01
- 提问者网友:wodetian
- 2021-02-09 12:35
现有字符变量ch1,已经被赋值,如何再将另一字符变量ch2中的数据追加到ch1中的内容之后
最佳答案
- 五星知识达人网友:十年萤火照君眠
- 2021-02-09 13:56
使用函数strcat(ch1,ch2);
将ch2连接到ch1末尾,使ch1成为新的字符串。
头文件 #include<string.h>
将ch2连接到ch1末尾,使ch1成为新的字符串。
头文件 #include<string.h>
全部回答
- 1楼网友:醉吻情书
- 2021-02-09 14:07
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.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯