I want to read text from a text file like so
Text File:
This is some text \nThis is the next line
However when I read it into a string and output it I get something like this
This is some text \nThis is the next line
//Expected Output
This is some text
This is the next line
Code:
void LoadTexts(const std::string& filepath) {
std::ifstream reader(filepath);
if (reader.is_open()) {
while (!reader.eof()) {
std::string str;
while (true) {
std::string readStr;
//reader >> readStr;
std::getline(reader, readStr);
if (readStr == ">") break;
str += readStr;
}
texts.push_back(str);
}
reader.close();
}
}