目录

size

描述 (Description)

它以字节为单位返回字符串的长度。

声明 (Declaration)

以下是std :: string :: size的声明。

size_t size() const;

C++11

 size_t size() const noexcept;

参数 (Parameters)

没有

返回值 (Return Value)

它以字节为单位返回字符串的长度。

异常 (Exceptions)

永远不要抛出任何例外

例子 (Example)

在下面的示例中为std :: string :: size。

#include <iostream>
#include <string>
int main () {
   std::string str ("Sairaqmkrishna Mammahe");
   std::cout << "The size of str is " << str.size() << " bytes.\n";
   return 0;
}

样本输出应该是这样的 -

The size of str is 22 bytes.
↑回到顶部↑
WIKI教程 @2018