Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: All
Jul 30, 1999

Another Technique of Marking Line Continuation

When a long line of a quoted string has to be broken, you can use the line continuation marker as described in the tip Use the Continuation Marker Before a Line Break. However, both C and C++ offer another method of breaking long lines, which relies on the fact that when the compiler sees: "literal 1"<whitespace>"literal 2", it will automatically concatenate the two strings:

 
printf("This is a string "
       "that will just get concatenated on to the other one "
       "and this one too" ); //the compiler concatenates the three quoted strings into a long string

As opposed to using a backslash to mark line continuation, this technique enables you to indent the strings however you like.

Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date