"ulrich" <ua********@aon.at> wrote in message
news:opstwijefhn2mgp5@innsbruck-neu...
: > myfont2.family = "times new roman";
:
: imho, you'll get a problem with just storing a pointer to a character
: sequence, which will be gone as soon as the above line has been executed.
Not at all: string literals have static storage.
In other words, the above line is equivalent to:
static char const anonymous_string_literal[] = "times new roman";
myfont2.family = anonymous_string_literal;
The storage of string literals persists until program exit.
: your struct should contain char family[MAX_NUMBER_OF_CHARS + 1] instead of
: char* family!
No, this would expose you to a whole range of serious
bugs (i.e. buffer overruns). If a 'naked' char const*
is inadequate, better use std::string .
I hope this helps,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com