void resize (size_t n);
void resize (size_t n, char c);

测试代码:
// resizing string
#include <iostream>
#include <string>

int main ()
{
  std::string str ("I like to code in C");
  std::cout << str << '\n';

  unsigned sz = str.size();

  str.resize (sz+2,'+');
  std::cout << str << '\n';

  str.resize (14);
  std::cout << str << '\n';
  return 0;
}

  

posted on 2016-04-07 19:24  小小八  阅读(1236)  评论(0编辑  收藏  举报