*edit*
Nevermind, it looks like I just needed to add a backslash:
Code:
found = str.find("\\n");
----------------------------
I'm searching for a sequence of characters in a string. I figured .find() would be my best bet. I can get it to work for most cases, except when I try to look for the following sequence of characters "\n".
So, my example string might look like:
Code:
The dog crossed \nthe street and he \nbarked at the neighbor.
*Note, the "\n" is actually in the text file. So, the above string would look exactly as it does now - all on one line.
I can find other sequences of characters no problem. For example:
Code:
int found = -999;
found = str.find("do");
cout << found << endl;
This will return the correct position. However, if I do:
Code:
int found = -999;
found = str.find("\n");
cout << found << endl;
It will return -1.
I know it has something to do with '\n' representing newlines, but I can't quite figure out how to actually find "\n" in the string.
In case you are wondering, I am just trying to replace any occurences of "\n" with an actual new line.
So my output would look like:
Code:
The dog crossed
the street and he
barked at the neighbor.
Maybe there is a better way to do this?
Any ideas?