   char strings legal
  ha i didn't know this was legal char *str = "hello""world";it is at least with VC compiler don't know if it standard or whatever. just a funny tid bit.   
  Yea, it's useful when you have a long string literal, and you want to break it into several lines.std::string text = "lots of stuff that is""too much to fit on one""line, so I put it on""multiple lines.";I presume it's a compromise, since they don't allow this syntax:std::string text = "lots of stuff" + "more stuff"; //<-- WrongI'm not sure if it's standard, but I've used it a few times with MinGW.   ;  Consecutive string literals are concatenated into one string literal at compile time. Perfectly fine and standard.   ;  You can also use the backslash to concatenate several lines together, which means you can have a single set of quotes spanning multiple lines (well, that's what it looks like to you; to the compiler, it looks like a single line).   ;Quote:Original post by quackdon't know if it standardIt is, see Section 2.14.5 Paragraph 12:Quote:In translation phase 6 (2.2), adjacent string literals are concatenated.;Quote:Original post by nullsquaredYou can also use the backslash to concatenate several lines together, which means you can have a single set of quotes spanning multiple lines (well, that's what it looks like to you; to the compiler, it looks like a single line).I think using a backslash tends to be more useful when dealing with lengthy macros which must be on a single line (as seen by the compiler). This aids readability for the programmer while still allowing the compiler to correctly process the macro.   ;Quote:Original post by quackha i didn't know this was legal char *str = "hello""world";When compiling with gcc (and hopefully VC too) you get a warning if you do that, since you can't change a string literal. const char *str = "hello""world"; is ok though.;Quote:Original post by PerostQuote:Original post by quackha i didn't know this was legal char *str = "hello""world";When compiling with gcc (and hopefully VC too) you get a warning if you do that, since you can't change a string literal. const char *str = "hello""world"; is ok though.I believe you are correct.  Without the const, should char* types be assigned with strcpy?;Quote:Original post by argonautQuote:Original post by PerostQuote:Original post by quackha i didn't know this was legal char *str = "hello""world";When compiling with gcc (and hopefully VC too) you get a warning if you do that, since you can't change a string literal. const char *str = "hello""world"; is ok though.I believe you are correct.  Without the const, should char* types be assigned with strcpy?There are numerous ways in which they can be assigned, not just strcpy(). For instance there is strcat() and strncat() as well as a plethora of other standard functions.   ;Quote:Original post by PerostQuote:Original post by quackha i didn't know this was legal char *str = "hello""world";When compiling with gcc (and hopefully VC too) you get a warning if you do that, since you can't change a string literal. const char *str = "hello""world"; is ok though.IIRC it is allowed because C allowed it.edit: that is to say it does not require the constant keyword, not that it can be modified.   