C++中empty()作为判断容器是否为空的函数;

#include <iostream>

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

    if (s.empty()) {
        std::cout << "字符串为空" << std::endl;
    }
    else {
        std::cout << "字符串不为空" << std::endl;
    }
}

Logo

云原生社区为您提供最前沿的新闻资讯和知识内容

更多推荐