Jump to content
  • Advertisement
Sign in to follow this  
chippolot

Compiler won't let me "put a newline in constant..." but I want to!

This topic is 5471 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

haha, this is a pretty simple question. So, I have a REALLY long message box function (dialogue boxes aren't an option) and I want to put in on more than one line in the source code file. Example::
MessageBox(hWnd, "blah blah blah blah blah blah blah 
                  blah blah", "blah", MB_OK);


But the compiler, VC .NET 7.1, won't let me... it gives me the error: new line in constant. Is there a way to break a constant char string onto more than one line in the source code? I don't want to have just one really long message box function on one line.... Thanks!

Share this post


Link to post
Share on other sites
Advertisement
MessageBox(hWnd, "This is a really long"
" string which has no newlines", MB_OK);

MessageBox(hWnd, "This is a really long\n"
"string which has one newline", MB_OK);


MessageBox(hWnd, "strings" " " "are" " " "fun", MB_OK);

Share this post


Link to post
Share on other sites

MessageBox(hWnd, "blah blah blah blah blah blah blah "
"blah blah", "blah", MB_OK);


You are right that the compiler do not accept newlines in constants, but it can concats litteral strings together.

(edit: and I'm again too slow. I'll cut the hands of Sneftel and uavfun.)

HTH,

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
tried this way

MessageBox(hWnd, "Line1\nLine2\Line3", "3Lines", MB_OK);

??

should put out a msgBox with 3 lines of text

Line1
Line2
Line3

'\n' is ESC-char for newline, well i guess at least

correct me if iam wrong

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!