.h to c string w/o resources?

.h to c string w/o resources?

Post by Ando Sonen » Sun, 03 Aug 2003 10:03:59


Gang,

I have some .h files that contain a bunch of text that I want to convert to
c string (or a ptr/size combo) at runtime.

Normally, one would put text into a resource of some type and load it at run
time, but I'm wanting to, in my C++ code, convert a codewarrior .h file into
said c string or ptr/size combo.

I feel like it's a longshot, but I'm hoping that there's a way to do this?

Alas, if C would only let me define multiline strings, I wouldn't have to do
such backwards things...

Thx,
Ando
 
 
 

.h to c string w/o resources?

Post by David Phil » Sun, 03 Aug 2003 14:01:51

In article <BB505C0E.DF34% XXXX@XXXXX.COM >,



char * aMultiLineString =

"this is the first line\n"
"and this is the second line\n"
"and this is the third line\n";


String constants seperated by white space are always automaticly
concatenated in C and C++.

But, why put them in a header file?

Ususally, you'd just do:

/* MyHeader.h */
extern char * aMultiLineString;

/* MyHeader.c */
#include "MyHeader.h"
char * aMultiLineString =
"this is the first line\n"
"and this is the second line\n"
"and this is the third line\n";


(We include the header in the .c so the compiler can check that the code
and the header are consistent.)