Finding carriage returns (\c) in a line
I'm trying to write a few lines of code that will take a line of input and replace an instance of "\c" with the carriage return character 0xD, and then search a document for that line of input.
For example, here's a test file (assume saved in Windows format, so each carriage return is \c\l):
What I want to do is search for "1\c" and have the program return "Line 1"
Another line 1 but not newline after
My current algorithm is:
However, this doesn't seem to be working. Any other ideas?
char c = 0xD;
string::size_type pos = contains.find("\\c");
string carriageReturn(1, c);
contains.replace(pos, 2, carriageReturn);