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 =)
2 Answers
+ 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")
0
In C#:
Console.Write("AAA\\nBBB");
In Java:
System.out.printf("AAA\\nBBB");