
C++ empty()函数
发布日期:2021-05-08 03:54:58
浏览次数:19
分类:精选文章
本文共 830 字,大约阅读时间需要 2 分钟。
文章目录
empty()
NULL空就返回1,其他返回0
bool empty() const noexcept;
Test if string is empty Returns whether the string is empty (i.e. whether its length is 0).This function does not modify the value of the string in any way. To clear the content of a string, see string::clear.
Parameters
noneReturn Value
true if the string length is 0, false otherwise.Example
// string::empty#include#include int main (){ std::string content; std::string line; std::cout << "Please introduce a text. Enter an empty line to finish:\n"; do { getline(std::cin,line); content += line + '\n'; } while (!line.empty()); std::cout << "The text you introduced was:\n" << content; return 0;}
Edit & Run
This program reads the user input line by line and stores it into string content until an empty line is introduced.
发表评论
最新留言
很好
[***.229.124.182]2025年04月11日 09时00分31秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
从头实现一个WPF条形图
2021-05-08
使用QT实现一个简单的登陆对话框(纯代码实现C++)
2021-05-08
QT :warning LNK4042: 对象被多次指定;已忽略多余的指定
2021-05-08
GLFW 源码 下载-编译-使用/GLAD配置
2021-05-08
针对单个网站的渗透思路
2021-05-08
Typescript 学习笔记六:接口
2021-05-08
02、MySQL—数据库基本操作
2021-05-08
OpenJDK1.8.0 源码解析————HashMap的实现(一)
2021-05-08
MySQL-时区导致的时间前后端不一致
2021-05-08
2021-04-05阅读小笔记:局部性原理
2021-05-08
go语言简单介绍,增强了解
2021-05-08
架构师入门:搭建基本的Eureka架构(从项目里抽取)
2021-05-08
MongoDB 快速扫盲贴
2021-05-08
one + two = 3
2021-05-08
sctf_2019_easy_heap
2021-05-09
PyQt5之音乐播放器
2021-05-09
Redis进阶实践之十八 使用管道模式提高Redis查询的速度
2021-05-09
SQL注入
2021-05-09
MPI Maelstrom POJ - 1502 ⭐⭐ 【Dijkstra裸题】
2021-05-09
Problem 330A - Cakeminator (思维)
2021-05-09