取一段、找一个、找不着

👁️ 1 人浏览 💬 0 人评论 ❤️ 添加收藏

(本条路线统一用 g++ -std=c++17 -O0 -Wall 编译)

#include <iostream>
#include <string>

int main() {
    std::string s = "hello world";

    std::string head = s.substr(0, 5);
    std::size_t at = s.find("world");
    std::size_t none = s.find("xyz");

    std::cout << s.size() << "/" << head << "/" << at << "/"
              << (none == std::string::npos) << "\n";
    return 0;
}
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论