How can you put escape characters (like newline character -- \n) to a CString?
Do you mean an unescaped version? If so then just escape the escape
CString("\\n");
The newline character is '\n' in single quotes. Just add that to your cstring.
I think your problem is not inserting a newline in the CString, but in the method that you are using to display the string
\n becomes a box (garbage character). it doesn't insert a new line.
Is this what you find in the debugger? If so, this is okay. The newline character has a hex value of 0xA or 10 in decimal. Since this is a non-printable character, that's what the debugger will show you.
Apart from that, if you are using notepad to view the output, it may not come out right. Try "\r\n" in order to get notepad to split correctly.
When I was a younger coder I had the same problem when writing to a .txt file on windows and opening it in notepad. The newline characters show up as these squares. If you want the appearance of newlines in notepad use "\r". This isn't really a solution, but I have an intuition that this is your problem...
CString strMessage = "";
strMessage.Format("Alpha \n Beta");
"\n" appears as box character in debugger but while displaying on the UI it displays properly.