Computer Science Canada

String literal ends at end of line

Author:  Lanks [ Thu Mar 26, 2009 8:24 am ]
Post subject:  String literal ends at end of line

WHAT?!?!?! can turing not handle

put "\"

if you run that it will give you an error : "String literal ends at end of line"
anyone know a workaround?

i am trying to draw a ghost using ascii and it won't place the backslashes...

Author:  DemonWasp [ Thu Mar 26, 2009 9:43 am ]
Post subject:  RE:String literal ends at end of line

Backslashes are an escape character, meaning that the second double-quote is being interpreted as part of the string, rather than the end of the string.

code:

To get this character, use this:
Char      Use
(tab)     \t
(return)  \n
"         \"
\         \\


In general, whatever character you put after a backslash is interpreted by Turing as being that literal character in the string, with the exceptions of t (tab), n (newline), and possibly r (return, but not line-feed).

What you want is put "\\" .

Edit: I should mention - this isn't a workaround. It's a feature. I'm not saying that in the sarcastic sense either, this really is a feature; it's the only way to get certain characters into strings.

Author:  andrew. [ Thu Mar 26, 2009 5:16 pm ]
Post subject:  RE:String literal ends at end of line

I know that Java does this as well. Like DemonWasp said, you can't work around it, it's built in to Turing.

Author:  DemonWasp [ Thu Mar 26, 2009 7:26 pm ]
Post subject:  RE:String literal ends at end of line

It's pretty standard; Java additionally allows for \u#### in some cases for internationalisation purposes.

Author:  Lanks [ Thu Mar 26, 2009 7:55 pm ]
Post subject:  RE:String literal ends at end of line

thanks! that will work just fine


: