0

Why \" done, what about \character not allowed?

13th Jan 2018, 9:13 AM
Yash Doshi
Yash Doshi - avatar
3 Answers
+ 2
\ is an escape character in lots of languages. With regex for example lots of characters have special meanings (. ? * > etc.) so if we actually want the specific character we have to use \. etc to tell the interpreter that "I actually want period, not a wildcard". This means that \ is also considered a special character, so to print one use \\ escaping the backslash. In your example, if we start a string with " and want to print a " inside the string, we have to tell it that this isn't a string end, but an actual quote mark. So really an escape character is a necessity, it's not that \ is not allowed
13th Jan 2018, 9:47 AM
Dan Walker
Dan Walker - avatar
+ 1
Which language ? Please put the language you use in the tags.
13th Jan 2018, 9:29 AM
sneeze
sneeze - avatar
13th Jan 2018, 9:29 AM
Yash Doshi
Yash Doshi - avatar