• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Stupid char* question?

## Recommended Posts

Hm, I don''t know how to begin... Well, I''ve got a friend who has a problem... :D Anyway, to keep this short I want to include quite a lot of text in my Windows program, and I will pass it all to an Edit Box using SendMessage with a char pointer as argument. So far all good! Now on to the embarrassing part... Since it''s a kind of long text, relatively speaking, I wonder how I can put this text into my code without it looking ugly... Is it possible to divide a char* text[] = "Some long text" into several lines, or do I have to place it all on one single line? I don''t like the one line approch that much really... Otherwise I will just turn the text into some custom resource, and get my char pointer from there, and the code will still look nice and all... How do you guys do when you have some text that you want included in the game?

##### Share on other sites
You can divide a string literal up with whitespace characters as much as you like. The compiler will concatenate consecutive string literal expressions within a statement to become a single expression. For example:
  int main(void){ char *lps = "this is " "some" " stuff";}

--
1st law of programming: Any given program, when running, is obsolete.

##### Share on other sites
great! Just what I needed... :D

##### Share on other sites
You might want to use a string table resource. Look up LoadString() function. I use string tables with MFC''s CString, which takes care of memory management issues.

• ### Forum Statistics

• Total Topics
627722
• Total Posts
2978804

• 10
• 9
• 21
• 14
• 12