C++ check if string is space or null

后端 未结 6 1297
死守一世寂寞
死守一世寂寞 2021-01-13 04:38

Basically I have string of whitespace \" \" or blocks of whitespace or \"\" empty in some of the lines of the files and I would

6条回答
  •  遥遥无期
    2021-01-13 05:28

    std::string str = ...;
    if (str.empty() || str == " ") {
        // It's empty or a single space.
    }
    

提交回复
热议问题