Andre Poenitz <[EMAIL PROTECTED]> writes:

| On Mon, Jul 29, 2002 at 10:02:23AM -0400, Kuba Ober wrote:
>> It does return a null terminated char const *, although please notice that 
>> this pointer may point to garbage on any subsequent line of your code, if the 
>> source QString was destroyed.
>> 
>> Thus, I'd always do this (unless I'm the one owning the QString):
>> 
>> char mybuf[512];
>> strncpy(mybuf, selectedFile().latin1(), sizeof(mybuf) - 1);
>> mybuf[sizeof(mybuf) - 1] = 0;
>> // sizeof()-1 so that the mybuf will always be zero-terminated
>> // even if latin1() returns a 512- or longer string
>
| And why don't you use
>
|  std::string mystr = selectedFile().latin1();

That will work.
... unless .latin1() can return NULL.

-- 
        Lgb

Reply via email to