string 的长度、下标与截取

单选题 难度 2

#string

下标从 0 开始。

题目

下面代码的输出是( )。

string s = "hello";
cout << s.size() << " " << s[1] << " " << s.substr(1, 3) << endl;
  1. 5 e ell
  2. 5 h hel
  3. 4 e ell
  4. 5 e ello
来小码星球,动手写一遍 →