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

#include <iostream>

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

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

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐