c++字符串 size和length的区别

size和length函数区别

#include 
#include 

int main() {
    std::string str = "Hello";
    
    // int size = str.size(); 
    int size = str.length();
    
    std::cout << "Size of the string: " << size << std::endl;
    
    return 0;
}

可能length 快些
[Done] exited with code=0 in 0.434 seconds
[Done] exited with code=0 in 0.393 seconds

你可能感兴趣的:(c++,leetcode)