C++ String clear()

2024年8月30日 | 阅读 1 分钟

此函数移除所有元素,使字符串变为空字符串。

语法

假设有一个字符串 str。语法为

参数

此函数不包含任何参数。

返回值

此函数不返回任何值。

示例

让我们看一个 clear() 函数的简单示例

输出

Enter some lines about javaTpoint and write dot character to finish the sentence
If you want to clear the text, press d

此示例展示了 clear() 函数的工作原理。


下一主题C++ 字符串