设为首页 加入收藏

TOP

计算机二级c++int转换成string类型代码
2014-11-23 20:06:49 来源: 作者: 【 】 浏览:42
Tags:计算机 二级 int 换成 string 类型 代码

  全国计算机等级考试资料下载


  //第一种方法
  #include
  #include
  using namespace std;
  int main()
  {
  int n = 65535;
  char t[256];
  string s;
  sprintf(t, "%d", n);
  s = t;
  cout << s << endl;
  return 0;
  }
  //第二种方法
  #include
  #include
  #include
  using namespace std;
  int main()
  {
  int n = 65535;
  strstream ss;
  string s;
  ss << n;
  ss >> s;
  cout << s << endl;
  return 0;
  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇GRETA正则表达式模板类库 下一篇计算机二级C++辅导:SetWindowsHoo..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: