LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
123
返回列表 发新帖
楼主: chemist

C++ STL 转换 string 大小写编译出错以及一个 C 中 strcpy 的问题

[复制链接]
发表于 2003-8-12 02:21:22 | 显示全部楼层

其实我知道还有个写法跟这个相类似


  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <cctype>

  5. using namespace std;

  6. int main(void)
  7. {
  8.         string s = "This is a TEST string.";
  9.         // original
  10.         cout << "orig: " << s << endl;

  11.         // to lower case
  12.         transform (s.begin(), s.end(), s.begin(),
  13.                       pointer_to_unary_function<int,int>(tolower));
  14.         cout << "lower: " << s << endl;

  15.         // to upper case
  16.         transform (s.begin(), s.end(), s.begin(),
  17.                       pointer_to_unary_function<int,int>(toupper));
  18.         cout  << "upper: " << s << endl;

  19.         return 0;
  20. }
复制代码


也是类型转化,但是不转的话,为什么就不行呢
发表于 2005-11-19 20:25:50 | 显示全部楼层
长知识了
谢谢各位
回复 支持 反对

使用道具 举报

发表于 2009-8-23 15:03:37 | 显示全部楼层
很好,很强大
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表