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的更多相关文章

  1. String类(C++练习二)

    字符串类(String),熟悉内存管理与拷贝控制 类定义 #include <iostream> //#include <cstring> using std::cout; u ...

  2. C++学习3--编程基础(vector、string、三种传参)

    知识点学习 Vector容器 vector是C++标准程序库中的一个类,其定义于头文件中,与其他STL组件一样,ventor属于STD名称空间: ventor是C++标准程序库里最基本的容器,设计之初 ...

  3. String 类实现 以及>> <<流插入/流提取运算符重载

    简单版的String类,旨在说明>> <<重载 #include <iostream> //#include <cstring>//包含char*的字符 ...

  4. ABAP--关于字符串String到XString XString to String转换代码

    转自http://guanhuaing.iteye.com/blog/1498891 代码如下 report zrich_0001. data: s type string, h(1) type x, ...

  5. string常用成员函数

    string常用成员函数 std::string::clear Clear string Erases the contents of the string, which becomes an emp ...

  6. C++ string类型小结

    目录 构造函数 string.append() string.assign() string.at() string.back() string.begin() string.capasity() s ...

  7. C++ string 常用函数总结

    头文件:#include<string> [注]:文中关于个数的参数文档中为 size_type 型,更本质是 size_t 型,因为typedef size_t size_type,而 ...

  8. ABAP 订单-交货单-发货过账自动完成 案例

    *&---------------------------------------------------------------------* *& Report  ZSDR006 ...

  9. SAP 直营验单

    *&---------------------------------------------------------------------* *& Report  ZSDR005 ...

随机推荐

  1. bootstrap基础学习【导航条、分页导航】(五)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. 在React native 如何写if判断和for循环

    在vue中一般在需要判断时都是通过if语句来实现的,但是在react native中一般则通过三元运算法来实现. 具体代码如下所示. import React from 'react'; import ...

  3. 滑动窗口协议(Sliding Window Protocol)

    滑动窗口协议(Sliding Window Protocol),属于TCP协议的一种应用,用于网络数据传输时的流量控制,以避免拥塞的发生.该协议允许发送方在停止并等待确认前发送多个数据分组.由于发送方 ...

  4. 【hash】Similarity of Subtrees

    图片来源: https://blog.csdn.net/dylan_frank/article/details/78177368 [题意]: 对于每一个节点来说有多少对相同的子树. [题解]: 利用层 ...

  5. deferred.promise.then().then()异步链式操作(Chain operation)

    //deferred.promise.then().then() deferred.promise.then(function () { console.log('1 resolve'); retur ...

  6. hdu 5230 整数划分 dp

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5230 题意:给定n,c,l,r.求有多少种方法从1~n-1选取任意k数每个数的权重为其下标,使得这些数字之 ...

  7. Bootstrap3 CDN 使用手册

    一.一般功能 <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel=" ...

  8. Xamarin(Android)制作启动画面

    1.将启动图片保存到Drawable文件夹下 2.在Drawable文件夹下创建splashscreen.xml <?xml version="1.0" encoding=& ...

  9. Java Web 深入分析(6) Tomcat

    tomcat是什么:汤姆猫?Javaweb服务器? Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache ...

  10. pyodbc报错pyodbc.InterfaceError

    connection = pyodbc.connect(r'Driver={SQL Server Native Client 11.0};Server=...;Database=...;Trusted ...