Builder Bob
Live free or don't
- Reaction score
- 249
I don't get what those escape characters are doing. (the \'s)
Let's say you want to print " to the screen. How would you do that when " marks the beginning and the end of a string. Where is the beginning and the end of the string """ ?
The escape character \ tells us that the following character in the string should be interpreted as a printable character in the string, no matter which character it is.
The string "\"" will therefor be printed as "
The escape character is also required to print the escape character itself.
"\\" is printed as \
Edit: Actually the escape character only tells us that the following character should have a different meaning than the usual one.
Example: \n is the same as new line. The character n is given a new meaning when combined with the escape character.