PDA

View Full Version : Binary file reading using Structure



umulingu
24th July 2009, 05:09
Hai

I want to use structure in my program to read binary file


typedef struct {
qint16 emptyData;
qint32 runno;
} CommonData;
CommonData CD;
dataStm>>CD; // dataStm-> QDATASTREAM , code not working....



succession please..

suresh R
India

nish
24th July 2009, 05:45
you have to overload operator<<() and operator>>() for your struct

umulingu
24th July 2009, 06:11
thanks



I want detailed code please

Lykurg
24th July 2009, 15:16
I want detailed code please
...and I want users who at least try to solve their own problems, before bothering us to deliver a complete solution!

umulingu
25th July 2009, 07:08
thanks for ur suggestion



I will try ..............

pdoria
25th July 2009, 10:43
you have to overload operator<<() and operator>>() for your struct

MrDeath,

I'm also interested in knowing how this overloading works as I've tried it without success...
TIA,
Pedro.

Lykurg
25th July 2009, 11:35
Take any book for c++, there will be a lot of examples how to overload a operator. For debug and struct use
friend QDebug operator<<(QDebug out, const YourStruct &s)
{
//...
}
The text stream works equal. And the place for the deklaration/definition you will find...