Qt-interest Archive, January 2006
Qt4.1.0 QDatastream problem char*
Message 1 in thread
Hi together!
I have overload the >> operator in my application, but I have troubles
to read out data in a char pointer.
Folowing theres a code snipe:
QDataStream& operator>>(QDataStream& s, SystemGeneral_t& sysGen)
{
char* tmpChar;
s >> tmpChar;
if(tmpChar)
trcpy(sysGen.projectTitle, tmpChar); /*delete[] tmpChar;*/
s.operator >>(tmpChar);
if(tmpChar)
strcpy(sysGen.dirName, tmpChar); /*delete[] tmpChar;*/
s >> sysGen.equationOfState >> sysGen.temperatureUnit >>
sysGen.pressureUnit
>> sysGen.stdTemp >> sysGen.stdPress >> sysGen.newNrOfComponents
>> sysGen.newComponent >> sysGen.addLibComp;
return s;
Message 2 in thread
Hi together!
Sorry I sent the previous email a little bit to fast!
I have overload the >> operator in my application, but I have troubles
to read out data in a char pointer.
Folowing theres a code snipe:
QDataStream& operator>>(QDataStream& s, SystemGeneral_t& sysGen)
{
char* tmpChar;
s >> tmpChar;
if(tmpChar)
strcpy(sysGen.projectTitle, tmpChar);
return s;
}
Please could anybody help me, I always get a NULL pointer back to
tmpChar!
Thanks!
best regards,
Christian
Message 3 in thread
Hi
how did you save your string to the file in the first place?
If you saved a QString you'll have to read a QString etc.
Michael Soukup
________________________________
Von: Christian Ranftl []
Gesendet: Do 26.01.2006 14:49
An: 'QT Newsletter'
Betreff: FW: Qt4.1.0 QDatastream problem char*
Hi together!
Sorry I sent the previous email a little bit to fast!
I have overload the >> operator in my application, but I have troubles to read out data in a char pointer.
Folowing theres a code snipe:
QDataStream& operator>>(QDataStream& s, SystemGeneral_t& sysGen)
{
char* tmpChar;
s >> tmpChar;
if(tmpChar)
strcpy(sysGen.projectTitle, tmpChar);
return s;
}
Please could anybody help me, I always get a NULL pointer back to tmpChar!
Thanks!
best regards,
Christian
--
[ signature omitted ]
Message 4 in thread
>
> char* tmpChar;
> s >> tmpChar;
>
I don't know if this is related to your specific problem, but with the
above you're attempting to write to uninitialized memory. That needs
fixing in any case.
Julian.
--
[ signature omitted ]
Message 5 in thread
Hi,
> I have overload the >> operator in my application, but I have troubles
> to read out data in a char pointer.
What sort of trouble? Compile-time or run-time? Any error messages?
--
[ signature omitted ]