Strings on web pagesTopFollow up courses for CS 51GEscape characters

Escape characters

We need a way to insert special characters in strings. For example, how do we insert a new line character into a string?

We can insert these special characters by prefixing them with \. For example, a new line is "\n", while a tab is "\t". Other characters require special handling because they mean other things in strings. For example, how do you include a double quote character in a string? Again, we can accomplish this with "\". Thus we type John said \"Good riddance!\" to get the string that reads John said "Good riddance!"

Other characters that require backslashes are { and } as well as \ itself.

Finally, it is possible to write any unicode letter by writing \uhhhh


Strings on web pagesTopFollow up courses for CS 51GEscape characters