Click here to Skip to main content
15,912,207 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Exporting Dialogs Pin
Christian Graus29-Mar-04 17:47
protectorChristian Graus29-Mar-04 17:47 
GeneralModalLess Dialog Pin
asv29-Mar-04 16:49
asv29-Mar-04 16:49 
GeneralRe: ModalLess Dialog Pin
Christian Graus29-Mar-04 17:48
protectorChristian Graus29-Mar-04 17:48 
GeneralRe: ModalLess Dialog Pin
22491729-Mar-04 18:31
22491729-Mar-04 18:31 
GeneralRe: ModalLess Dialog Pin
David Crow30-Mar-04 4:18
David Crow30-Mar-04 4:18 
GeneralRe: ModalLess Dialog Pin
asv30-Mar-04 17:04
asv30-Mar-04 17:04 
GeneralRe: ModalLess Dialog Pin
David Crow31-Mar-04 2:03
David Crow31-Mar-04 2:03 
Generalfile stream help pleaseeee Pin
strik29-Mar-04 16:37
strik29-Mar-04 16:37 
Hi,

I'm writing about 20kb of data into a binary file, but at some point during the file output (usually after a certain amount of objects are required to be saved to disk), some form of corruption occurs. Can anyone help with this? Here is some example code:

<br />
	ofstream myFile(lpszPathName, ios::binary || ios::trunc);<br />
<br />
	/* Write the File */<br />
	myFile.write((char*)(&version), sizeof(int));			// file version<br />
	myFile.write((char*)(&w0.numMeshes), sizeof(int));		// number of meshes<br />
	myFile.write((char*)(&w0.numLights), sizeof(int));<br />
    myFile.write((char*)(&p.pos.x), sizeof(float));<br />
	myFile.write((char*)(&p.pos.y), sizeof(float));<br />
	myFile.write((char*)(&p.pos.z), sizeof(float));<br />
<br />
	for(int m = 0; m < w0.numMeshes; m++)					<br />
	{<br />
		myFile.write((char*)(&w0.world_meshes[m]->numFaces), sizeof(int));<br />
		myFile.write((char*)(&w0.world_meshes[m]->numVerts), sizeof(int));<br />
		myFile.write((char*)(&w0.world_meshes[m]->numNormals), sizeof(int));<br />


etc... etc... going through all mesh faces, vertices and what not, and then finally a myFile.close().

Exactly the same happens for reading, but using file.read() instead. The read function is exactly the same as it's copied & pasted with just swapping of myFile.write to file.read, although there are a few initializations in between the reading lines which are not there during the writing lines.

It seems to be completely random, and I know this isn't possible in programming! It mostly happens when 12 objects need to be required to save to disk, although sometimes it works fine up to an infinite amount, other times, 5 or 6 objects can be written and the corruption starts.

I'm thinking along the lines of some kind of buffer error happening once it reaches a certain size? If anyone can help me on this problem I would be so greatful.

Yours desperately,
Nathan
GeneralRe: file stream help pleaseeee Pin
Antti Keskinen29-Mar-04 18:50
Antti Keskinen29-Mar-04 18:50 
GeneralRe: file stream help pleaseeee Pin
strik29-Mar-04 20:26
strik29-Mar-04 20:26 
GeneralRe: file stream help pleaseeee Pin
Robert A. T. Káldy29-Mar-04 22:41
Robert A. T. Káldy29-Mar-04 22:41 
GeneralRe: file stream help pleaseeee Pin
Antti Keskinen30-Mar-04 0:04
Antti Keskinen30-Mar-04 0:04 
GeneralRe: file stream help pleaseeee Pin
Roger Allen30-Mar-04 0:44
Roger Allen30-Mar-04 0:44 
GeneralRe: file stream help pleaseeee Pin
Antti Keskinen30-Mar-04 2:38
Antti Keskinen30-Mar-04 2:38 
GeneralRe: file stream help pleaseeee Pin
Robert A. T. Káldy30-Mar-04 5:08
Robert A. T. Káldy30-Mar-04 5:08 
GeneralRe: file stream help pleaseeee Pin
Antti Keskinen30-Mar-04 8:35
Antti Keskinen30-Mar-04 8:35 
GeneralSome questions about inline function Pin
nachilau29-Mar-04 16:26
nachilau29-Mar-04 16:26 
GeneralRe: Some questions about inline function Pin
Ryan Binns29-Mar-04 16:50
Ryan Binns29-Mar-04 16:50 
GeneralRe: Some questions about inline function Pin
Maxwell Chen29-Mar-04 16:52
Maxwell Chen29-Mar-04 16:52 
GeneralRe: Some questions about inline function Pin
Christian Graus29-Mar-04 17:49
protectorChristian Graus29-Mar-04 17:49 
GeneralRe: Some questions about inline function Pin
includeh1029-Mar-04 18:18
includeh1029-Mar-04 18:18 
GeneralRe: Some questions about inline function Pin
jhwurmbach30-Mar-04 2:35
jhwurmbach30-Mar-04 2:35 
GeneralRe: Some questions about inline function Pin
includeh1030-Mar-04 6:06
includeh1030-Mar-04 6:06 
GeneralListView_GetItemText crashes Outlook Pin
jphillips_2003@hotmail.com29-Mar-04 15:07
jphillips_2003@hotmail.com29-Mar-04 15:07 
GeneralRe: ListView_GetItemText crashes Outlook Pin
Ryan Binns29-Mar-04 16:53
Ryan Binns29-Mar-04 16:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.