Hi, I’m trying to make a program that can dynamically form an escape sequence character.
Please take a look at my code below.
void ofApp::keyPressed(int key){
string escapeSeq;
escapeSeq.push_back('\\');
escapeSeq.push_back((char)key);
string text = "Hello" + escapeSeq + "World";
cout << text << endl;
}
For example, If I press ‘n’ key, I’m expecting it to print out
Hello
World
But it actually prints out
Hello\nWorld
How can I make the program work? Thanks in advance!