且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与换行Windows C ++比较

更新时间:2023-01-29 16:58:26

您的 isNewline 函数没有问题。

问题是如何将字符串传递给 isNewline 函数。

The problem is how you get the string to be passed to isNewline function.

我怀疑您使用了类似 getline(fin,aLine)之类的字符串来获取如下字符串?

I suspect you use something like getline(fin,aLine) to get the string like below?

while(getline(fin,aLine)){
   cout<<aLine<<endl; //aLine will never contain newline character because getline never save it
   cout<<isNewline(aLine)<<endl; // so this will never output "(newline)"
}

getline 不会将换行符保存到 aLine

getline does not save the newline character into aLine