> -----Original Message-----
> From: Kenneth Albanowski [mailto:[EMAIL PROTECTED]]
> 
> 
> Yes. These mean two different things. If you create literal strings in
> this manner:
> 
>       char * foo = "string";
> 
>       bar("string");
> 
>       baz = 3 + "string";
> 
> then all those "string"'s will be in the code segment (assuming the
> compiler wants to, is capable, and hasn't been instructed 
> otherwise). 

I'm not so sure about that.  The first, if declared

        const char *foo = "string";

might very well put the "string" into the code segment, but if
it's declared just as you said (w/o the const) then isn't the
compiler smart enough to recognize that the string might get
written to & put it in a data segment?  (It's been a while 
since I dealt w/ this kind of stuff, go easy on me <g>)

> > What is the best way to store strings like that?
> 
> Logically, since the string _has_ to be in your program code, 
> put it in
> the code segment so that it won't _also_ take up RAM. If 
> you've got a lot
> of strings, you might consider storing them as separate resources. 

Storing them as resources I think is the best use of
your memory, because they will not be taking up part of
your precious 32k code segment, and they will only 
be taking up your valuable heap space when they are
loaded & being used.  Also it allows for localization
(i.e. translation into foriegn languages) if you're into
that sort of thing.  The downside is that it takes a 
little extra code and a lot of discipline to put all
your string literals into a resource.

-- 
-Richard M. Hartman
[EMAIL PROTECTED]

186,000 mi./sec ... not just a good idea, it's the LAW!

Reply via email to