运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 Spaces
#include <iostream> #include <string> using namespace std; int main() { string myString = "Hello"; cout << "Original string: " << myString << "\n"; cout << "First character: " << myString.at(0) << "\n"; cout << "Second character: " << myString.at(1) << "\n"; cout << "Last character: " << myString.at(myString.length() - 1) << "\n"; myString.at(0) = 'J'; cout << "Changed string: " << myString; return 0; }
原始字符串: Hello
第一个字符: H
第二个字符: e
最后一个字符: o
更改后的字符串: Jello