C++中empty()作为判断容器是否为空的函数;
#include <iostream>
int main() {
std::string s = "";
if (s.empty()) {
std::cout << "字符串为空" << std::endl;
}
else {
std::cout << "字符串不为空" << std::endl;
}
}
C++中empty()作为判断容器是否为空的函数;
#include <iostream>
int main() {
std::string s = "";
if (s.empty()) {
std::cout << "字符串为空" << std::endl;
}
else {
std::cout << "字符串不为空" << std::endl;
}
}