【发布时间】:2012-06-27 14:18:10
【问题描述】:
有没有办法编写一个跨平台解析器来读取字符直到找到换行符?我在 Linux 中使用 '\0',但我不确定这是否也可以在 Windows 上完成。
std::string line;
// fill the line
QTextStream ss(&line);
for(;;)
{
ss >> c;
if(c == '"' || c=='\0' ) // here I want to continue parsing until a new-line character or a ending double quote is found
break;
}
【问题讨论】:
-
你知道
\0不是换行符吧? -
不能先使用
std::getline从流中获取一行然后解析吗? -
如果您使用标准流进行格式化输入,那么
'\n'是您的事……我猜 Qt 也是如此。