1 #include <cstdlib> // For ``EXIT_FAILURE'' constant
7 int main(int argc
, char *argv
[])
10 float x
, y
, z
, xR
, yR
, zR
, t
;
11 quint32 i
, magicNumber
;
14 file
.setFileName(argv
[1]);
16 // Open file for writing
17 file
.open(QIODevice::WriteOnly
);
18 QDataStream
out(&file
);
20 // Write a header with a "magic number" and a Qt version
21 out
<< (quint32
)0xA0B0C0D0;
22 out
.setVersion(QDataStream::Qt_4_3
);
25 for (i
= 0; i
< 100; i
++) {
26 for (t
= 0.0; t
< 50.0; t
+= 1.0) {
27 out
<< (float) (5.0 * t
* t
) << 0.0f
<< 0.0f
28 << (float) (cos(t
) * 180.0) << 0.0f
<< 0.0f
;
33 // Open file for reading
34 file
.open(QIODevice::ReadOnly
);
35 QDataStream
in(&file
);
37 // Read "magic number" and Qt version
39 if (magicNumber
!= 0xA0B0C0D0) {
40 std::cout
<< "Magic number mismatch\n";
45 if (qtVersion
!= QDataStream::Qt_4_3
) {
46 std::cout
<< "Qt Version mismatch\n";
50 std::cout
<< "Magic number = 0x" << std::hex
<< magicNumber
<< "\n";
51 std::cout
<< "Qt Version = 0x" << qtVersion
<< "\n";
55 in
>> x
>> y
>> z
>> xR
>> yR
>> zR
;
56 std::cout
<< "x = " << x
61 << "\tzR = " << zR
<< "\n";