Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 String literal ends at end of line
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lanks




PostPosted: 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...
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: 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.
andrew.




PostPosted: 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.
DemonWasp




PostPosted: 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.
Lanks




PostPosted: Thu Mar 26, 2009 7:55 pm   Post subject: RE:String literal ends at end of line

thanks! that will work just fine
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: