I have a question on how to include string literals when getting info from a file. Let me show my code for better understanding:
Program.b:
print \"Hello World\n\"; print \"Commo Estas :)\n\"; print \"Bonjour\";print \"Something\"; return 0;
main.cpp (I have minimized the actual file to what is needed for this question):
int main()
{
std::string file_contents;
std::fstream file;
file.open("Program.b");
std::ifstream file_read;
file_read.open("Program.b");
if(file_read.is_open())
while(getline(file_read,file_contents));
cout << file_contents << endl;
}
So right now when I print file_contents
, I get:
print \"Hello World\n\"; print \"Commo Estas :)\n\"; print \"Bonjour\";print \"Something\"; return 0;
You can see it includes the \n
. Is there a way to make that an actual character literal, so printing it actually prints a new line? (I would want the same for quotation marks.)