首页 > 编程知识 正文

c++strlen函数用法,vb instr函数

时间:2023-05-04 22:34:19 阅读:15784 作者:4226

resize (,设置大小;

reserve (,设置容量;

resize ) )分配容器的内存大小,而reserve ) )只是设置容器的容量大小,而不是实际分配内存。

resize (可以传递两个参数:大小和初始值。 默认值为0,reserve ) )只能传递一个参数,不能设置初始值。 初始值由系统随机生成。

示例:

# include iostream # include cstring # include cstdio # includevectorusingnamespacestd; int main () {vectorintm; 向量Intn; 向量输入; m.resize(10; n .保留(10; s.resize (10,6 ); cout 'm: '; for(intI=0; i 10; I ) {cout m[i] '; }cout endl; cout 'n: '; for(intI=0; i 10; I ) {cout n[i] '; }cout endl; cout 's: '; for(intI=0; i 10; I ) {cout s[i] '; }cout endl; 返回0; }输出:

m :0000000 n :12999640129799040000000 s 3360666666666

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。