-1

I'm starting to write more intricate code that does some dynamic compilation through Lua and OpenGL. However, my code is starting to get kinda messy because I have many const char* strings and strings in sections of my code so they can be parsed together properly depending on specific conditions. The only method I know for structuring strings across multiple lines is:

const char* foo = "1\n\
2\n\
3";

prints --
1
2
3

Is there a better way as this looks messy? Maybe some method of using \b*number.

Visual Studio automatically does this but unfortunately it puts all the spaces on the line leading too it.

const char* foo = "1\n\
                   2\n\
                   3";
prints --
1
                   2
                   3

I don't really want to do \b\b\b\b\b\b\b\b\b\b\b\b\b\b or something silly or even count the backspaces unless I have to. Any ideas?

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ChaseRLewis
0

one way is:

const char* foo = "\n1\n2\n3\n4"

another is

char* foo[] = {"1", "2", "3"}
int count = 3;
for(i=0;i<3;i++)
  printf("\n%s", foo[i]);
-1

Guess nothing as convenient as lua's --[[ --]] operators. Never really had a need for such long strings so never really looked into it.

Votes + Comments
What's the purpose of this post?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.