Click here to Skip to main content
15,899,026 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generallesson learned Pin
CABS7-May-04 9:15
CABS7-May-04 9:15 
AnswerRe: how do i get the source code back Pin
jmkhael7-May-04 5:52
jmkhael7-May-04 5:52 
GeneralRe: how do i get the source code back Pin
CABS7-May-04 6:10
CABS7-May-04 6:10 
Generalyes Pin
CABS7-May-04 6:11
CABS7-May-04 6:11 
AnswerRe: how do i get the source code back Pin
toxcct7-May-04 6:08
toxcct7-May-04 6:08 
Generalthnx Pin
CABS7-May-04 6:12
CABS7-May-04 6:12 
QuestionHow to handle the disabled icon in the main menu? Pin
Cyrus Dang7-May-04 4:51
Cyrus Dang7-May-04 4:51 
Generalsaving in binary files Pin
Tagamoga7-May-04 4:22
Tagamoga7-May-04 4:22 
Hello.

I have an understanding problem with saving complete classes to an binary file.

//First example:


<br />
Class myAnimal<br />
{<br />
int age;<br />
int legs;<br />
...<br />
}<br />
...<br />
myAnimal Bear(2, 4);<br />
fout.write((char*) Bear, sizeof Bear);<br />
fout.close();<br />
<br />
// to read this thing:<br />
...<br />
fin.read((char*)&Bear, sizeof Bear);<br />


every thing is fine

// Second example:

<br />
Class myAnimal<br />
{<br />
int age;<br />
int legs;<br />
...<br />
}<br />
Class myBird<br />
{<br />
int age;<br />
int legs;<br />
...<br />
}<br />
...<br />
myAnimal Bear(2, 4);<br />
fout.write((char*) Bear, sizeof Bear);<br />
myBird Tweety(6, 2);<br />
fout.write((char*) Tweety, sizeof Tweety);<br />
fout.close();<br />
<br />
// to read:<br />


how do I know which class is now read from the file?!?!?!

// Third example:

<br />
Class myAnimal<br />
{<br />
int age;<br />
int legs;<br />
...<br />
}<br />
class Cage<br />
{<br />
myAnimal Bears[10];<br />
}<br />
<br />
// have I now to store each single Bear to the file or is there a possiblity to wirte something similar to<br />
Cage Bearcage();<br />
fout.write((char*) Bearcage, sizeof Bearcage);<br />
fout.close();<br />


and will be every single Bear be stored, or do I have to do it for each single Bear? How do I load these Bears? Every single one?


Sorry for my bad english, but I hope you understand my problem. Thank for help.

Taggi

How do you know, that Tagamoga has been assimilated by the borg?
"Recistunce ist fiutille."
Sorry for violating the english language.
GeneralRe: saving in binary files Pin
David Crow7-May-04 4:54
David Crow7-May-04 4:54 
GeneralRe: saving in binary files Pin
Tagamoga7-May-04 7:50
Tagamoga7-May-04 7:50 
GeneralRe: saving in binary files Pin
David Crow7-May-04 8:16
David Crow7-May-04 8:16 
GeneralRe: saving in binary files Pin
Tagamoga7-May-04 11:16
Tagamoga7-May-04 11:16 
Generaldialog with a connect button Pin
Ghadir7-May-04 4:13
Ghadir7-May-04 4:13 
GeneralRe: dialog with a connect button Pin
David Crow7-May-04 4:56
David Crow7-May-04 4:56 
GeneralRe: dialog with a connect button Pin
toxcct7-May-04 5:02
toxcct7-May-04 5:02 
GeneralID3V2 manipulation with id3lib Pin
Paolo Ponzano7-May-04 3:48
Paolo Ponzano7-May-04 3:48 
GeneralApplication freezes while loading DLLs Pin
Member 5343577-May-04 3:29
Member 5343577-May-04 3:29 
GeneralRe: Application freezes while loading DLLs Pin
Jens Doose7-May-04 3:31
Jens Doose7-May-04 3:31 
GeneralRe: Application freezes while loading DLLs Pin
Member 5343577-May-04 4:05
Member 5343577-May-04 4:05 
GeneralRe: Application freezes while loading DLLs Pin
Jens Doose7-May-04 4:09
Jens Doose7-May-04 4:09 
GeneralRe: Application freezes while loading DLLs Pin
Member 5343577-May-04 4:53
Member 5343577-May-04 4:53 
GeneralRe: Application freezes while loading DLLs Pin
Jens Doose9-May-04 23:19
Jens Doose9-May-04 23:19 
GeneralRe: Application freezes while loading DLLs Pin
Member 53435710-May-04 2:46
Member 53435710-May-04 2:46 
GeneralRe: Application freezes while loading DLLs Pin
basementman7-May-04 4:47
basementman7-May-04 4:47 
GeneralRe: Application freezes while loading DLLs Pin
Member 5343577-May-04 4:52
Member 5343577-May-04 4:52 

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.