Kuba Ober <[EMAIL PROTECTED]> writes:

| On środa 24 lipiec 2002 04:10 am, Angus Leeming wrote:
>> On Wednesday 24 July 2002 7:25 am, Lars Gullik Bjønnes wrote:
>> > Just make sure that QString::data is required to retrun a
>> > null-terminated char const *.
>>
>> const char* data() const { return latin1(); }
>>
>> I don't have the Qt src to hand so can't dig any further.
>
| 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

So QString does not have a copy function? Like std::string does`

btw. what if the string is longer than 512?

-- 
        Lgb

Reply via email to