|
From: Hans-Bernhard B. <br...@ph...> - 2004-03-01 12:56:53
|
On Mon, 1 Mar 2004, Dave Denholm wrote:
> Aren't string literals merely a convenience feature. You can implement
> things explicitly as
>
> static const char label1[] = "hello world\n";
Sure. The core problem is with large arrays of string literals...
Technically, that makes them 2D arrays, and for those, you can't
have the "inner" dimension (i.e. the lengths of individual strings)
variable. That would mean we either
static const char PS_header[][60] = {
"line 1\n",
"line2\n",
/*... */
};
and waste even more space than we currently do, because of variations in
line lengths, or declare each line as an individual, named string
variable, and construct the array from pointers to those strings:
static const char line1[]="line1\n";
static const char line2[]="line2\n";
/*...*/
static const char *PS_header[] = {
line1,
line2,
/* ... */
};
The problem at hand is not with string literals as such, but with large
collections of them, and with keeping the source code at least barely
legible and extensible.
--
Hans-Bernhard Broeker (br...@ph...)
Even if all the snow were burnt, ashes would remain.
|