I have this simple code:
string isNewline(string text)
{
string toReturn;
text == "\r\n" ? toReturn = "(newline)" : toReturn = text;
return toReturn;
}
this function never returns a “(newline)” string, so I’m guessing that my comparison with newline character is wrong. How can I correct this?
PS. Windows function
There is nothing wrong with your
isNewlinefunction.The problem is how you get the string to be passed to
isNewlinefunction.I suspect you use something like
getline(fin,aLine)to get the string like below?getlinedoes not save the newline character intoaLine