我目前正在打开一个文件并使用 getline(x,y) 读取它,但我想在遇到空格时停止读取该行,然后从那里继续读取。 谢谢
最佳答案
格式化输入将在空白处停止:
std::string str;
while( file >> str)
std::cout << str << std::endl;
也许您正在寻找 isspace( int ch)
方法:
#include <cctype>
if ( isspace( string.at(i)))
// ... stop
关于c++ - 遇到空格时如何停止阅读一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28519966/