Chinaunix首页 | 论坛 | 博客
  • 博客访问: 359766
  • 博文数量: 100
  • 博客积分: 2500
  • 博客等级: 大尉
  • 技术积分: 1209
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-15 21:24
文章分类

全部博文(100)

文章存档

2011年(100)

分类: C/C++

2011-04-21 14:05:52

  1. const char& operator[] ( size_t pos ) const;
  2.       char& operator[] ( size_t pos );
  3. //Returns a reference the character at position pos in the string.
  1. const char& at ( size_t pos ) const;
  2.       char& at ( size_t pos );
  3. //Returns the character at position pos in the string.
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;

  4. int
  5. main(void)
  6. {
  7.         string str ("Hello");
  8.         int i;
  9.         for (i = 0; i < str.length(); i++)
  10.                 cout << str[i];

  11.         cout << endl;

  12.         for (i = 0; i < str.length(); i++)
  13.                 cout << str.at(i);

  14.         cout << endl;

  15.         return (0);
  16. }

阅读(1157) | 评论(0) | 转发(0) |
0

上一篇:String III Capacity

下一篇:String V Modifier

给主人留下些什么吧!~~