C++ String empty() 函数
定义和用法
empty()
函数用于检查字符串是否为空。
如果字符串为空,则返回 1;否则返回 0。
实例
判断字符串是否为空:
string txt1 = "Hello World!"; string txt2 = ""; cout << txt1.empty(); cout << txt2.empty();
语法
string.empty();
参数
无。
技术细节
返回: |
一个布尔值:
|
---|
相关页面
教程:C++ 字符串
教程:C++ 布尔值