码迷,mamicode.com
首页 > 其他好文 > 详细

string::clear

时间:2019-12-23 19:13:51      阅读:73      评论:0      收藏:0      [点我收藏+]

标签:对象   text   ace   std   ext   mes   int   ret   pac   

void clear() noexcept;
功能:把string对象置为空

#include <iostream>
#include <string>

using namespace std;

int main()
{
char c;
string str;
cout << "please enter text\n";
do{
c = cin.get();
str += c;
if(c == ‘\n‘)
{
cout << str;
str.clear();
}
}while(c != ‘.‘);
return 0;
}

 

string::clear

标签:对象   text   ace   std   ext   mes   int   ret   pac   

原文地址:https://www.cnblogs.com/xpylovely/p/12085044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!