0

I have a very long line:

const string a_string = "a long string with \" .. with \" again ... ... ";

Now this string goes really long, how do I wrap up the line in an elegant way? I tried just break line but it doesn't work. I am actually not sure if this is a IDE problem or compiler problem... Please help!

WhatABeautifulWorld
  • 3,198
  • 3
  • 22
  • 30
  • 1
    The linked question is for C/Objective-C, but the solution is exactly the same as in C++. Possible duplicate of [How to split a string literal across multiple lines in C / Objective-C?](https://stackoverflow.com/questions/797318/how-to-split-a-string-literal-across-multiple-lines-in-c-objective-c) – scohe001 Mar 26 '18 at 23:25
  • 2
    Do you want the line breaks to appear in the string itself (i.e. visible to the program's user) or do you want the string to be a single-line string as far as the user is concerned, but have it appear as multiple lines in your IDE? – Jeremy Friesner Mar 26 '18 at 23:26
  • Do you need line wrap in a GUI, Console or something else? – Alex Mar 26 '18 at 23:26

1 Answers1

9

Try

const string a_string = "a long string "
                        "with \" .. with \" "
                        "again ... ... ";
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
DigitalEye
  • 1,456
  • 3
  • 17
  • 26