Finding carriage returns (\c) in a line
Hi all:
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):
Code:
Line 1
Line 2
Line 3
Another line 1 but not newline after
What I want to do is search for "1\c" and have the program return "Line 1"
My current algorithm is:
Code:
char c = 0xD;
string::size_type pos = contains.find("\\c");
string carriageReturn(1, c);
contains.replace(pos, 2, carriageReturn);
However, this doesn't seem to be working. Any other ideas?
Thanks.