我有如下功能:读线,结尾没有“ r”字符
void process (std::string str)
{
std::istringstream istream(str);
std::string line;
std::string specialStr("; -------- Special --------------------\r"); // win
//std::string specialStr("; -------- Special --------------------"); //linux
while (getline(istream,line))
{
if (strcmp(specialStr.c_str(), line.c_str()) != 0)
{
continue;
}
else
{
//special processing
}
}
}
我读通过线的std :: istringstream行线,采用getline
,直到我“见面“特殊字符串 之后我应该为下一行做一些特殊处理。 特殊字符串是:
; -------- Special --------------------
当我在阅读窗口的相应行线将其与 '\ r' 端:
(; -------- Special --------------------\r
) 在Linux中没有 '\ R' 出现在末尾。 有没有一种方法可以一致地读取这些行,而无需区分它是linux还是windows?
感谢
你是否可能以二进制模式打开了流? – jrok 2013-04-28 13:29:48
std :: string str; //是一个参数std :: istringstream isaStream(str); //这样我打开stringstream – Yakov 2013-04-28 13:31:50
你从哪里得到'str'的内容? (你可以张贴一些代码,你懂的) – jrok 2013-04-28 13:33:06