1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
struct vert
{
float x, y, z;
float nx, ny, nz;
float tx, ty, tz;
float bx, by, bz;
float tu, tv;
};
struct myFile
{
vert v;
};
void writeOutFile()
{
FILE* f;
struct myFile myRecord;
f = fopen("test.binary","w");
for(int i = 0; i <= 10000; i++)
{
myRecord.v.x = float(i);
fwrite(&myRecord, sizeof(struct myFile), 1, f);
}
fclose(f);
}
void readInFile()
{
FILE* f;
struct myFile myRecord;
f = fopen("test.binary","r");
for(int i = 0; i <= 10; i++)
{
fread(&myRecord, sizeof(struct myFile), 1, f);
logFile.open("read.log");
logFile << "vx: " << myRecord.v.x << std::endl;
logFile.close();
}
fclose(f);
}
|