0

How to print exact backslash with n

Hi, what if we want to print "Hello \nWorld" ? I mean, if we just need to print "backslash and lower-case n " in a string What can I do to have the outcome below: AAA/nBBB instead of AAA BBB Thank you for reply =)

20th Nov 2016, 3:15 AM
Zachary S. Chao
Zachary S. Chao - avatar
2 Réponses
+ 3
You need to escape the backslash by adding another backslash before it. In C: printf("AAA\\nBBB"); In C++: cout << "AAA\\nBBB"; In Python 3: print("AAA\\nBBB")
17th Nov 2016, 10:00 PM
Arthur Busser
Arthur Busser - avatar
0
In C#: Console.Write("AAA\\nBBB"); In Java: System.out.printf("AAA\\nBBB");
20th Nov 2016, 5:44 AM
Samuel Neo
Samuel Neo - avatar