Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: File read-plz help me? Pin
ThatsAlok16-May-07 19:38
ThatsAlok16-May-07 19:38 
QuestionFont of command buttons on property pages Pin
Neeraj Sinha5-May-07 1:19
Neeraj Sinha5-May-07 1:19 
AnswerRe: Font of command buttons on property pages Pin
prasad_som5-May-07 1:54
prasad_som5-May-07 1:54 
GeneralRe: Font of command buttons on property pages Pin
Neeraj Sinha5-May-07 2:03
Neeraj Sinha5-May-07 2:03 
GeneralRe: Font of command buttons on property pages Pin
prasad_som6-May-07 20:59
prasad_som6-May-07 20:59 
Questionhow to wisely use memory to store data Pin
cy163@hotmail.com5-May-07 1:18
cy163@hotmail.com5-May-07 1:18 
AnswerRe: how to wisely use memory to store data Pin
Hans Dietrich5-May-07 2:14
mentorHans Dietrich5-May-07 2:14 
AnswerRe: how to wisely use memory to store data Pin
Mark Salsbery5-May-07 6:48
Mark Salsbery5-May-07 6:48 
To add to Hans Dietrich's reply...

Serialization works good for this IMO.

You could make the class(struct) serializable -
// Note:  Simple example - missing overrun checking, error handling, etc.
 
struct S{
   char Name[20];
   int score;
 
   void Serialize(CFile &file);
   void Unserialize(CFile &file);
}
 
void S::Serialize(CFile &file)
{
   WORD wStrLen = (WORD)strlen(Name);
   file.Write(&wStrLen, sizeof(WORD));
   if (wStrLen > 0)
      file.Write(Name, wStrLen);
   file.Write(&score, sizeof(int));
}
 
void S::Unserialize(CFile &file)
{
   WORD wStrLen;
   file.Read(&wStrLen, sizeof(WORD));
   if (wStrLen > 0)
      file.Read(Name, wStrLen);
   Name[wStrLen] = '\0';
   file.Read(&score, sizeof(int));
}

To write an S object to a file, call Serialize().
To read an S object from a file, call Unserialize().

Also, since you're using MFC, MFC's built-in CObject serialization is available.

Mark


"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

Questionstring copy problem in structure variable Pin
amitmistry_petlad 5-May-07 0:21
amitmistry_petlad 5-May-07 0:21 
AnswerRe: string copy problem in structure variable Pin
Hans Dietrich5-May-07 0:49
mentorHans Dietrich5-May-07 0:49 
GeneralRe: string copy problem in structure variable Pin
amitmistry_petlad 5-May-07 1:01
amitmistry_petlad 5-May-07 1:01 
AnswerRe: string copy problem in structure variable Pin
amistry_petlad12-Apr-10 12:49
amistry_petlad12-Apr-10 12:49 
QuestionHow To change degault font of ToolTip control? Pin
Atul234-May-07 23:38
Atul234-May-07 23:38 
Questionerror problem Pin
anu jaggi4-May-07 23:02
anu jaggi4-May-07 23:02 
AnswerRe: error problem Pin
amitmistry_petlad 4-May-07 23:58
amitmistry_petlad 4-May-07 23:58 
QuestionCreate Registry Entry in Vista ... Pin
Manjunath S4-May-07 22:33
Manjunath S4-May-07 22:33 
AnswerRe: Create Registry Entry in Vista ... Pin
prasad_som4-May-07 22:50
prasad_som4-May-07 22:50 
GeneralRe: Create Registry Entry in Vista ... Pin
Manjunath S4-May-07 22:56
Manjunath S4-May-07 22:56 
AnswerRe: Create Registry Entry in Vista ... Pin
Sameer_Thakur4-May-07 23:03
Sameer_Thakur4-May-07 23:03 
GeneralRe: Create Registry Entry in Vista ... Pin
Manjunath S4-May-07 23:21
Manjunath S4-May-07 23:21 
GeneralRe: Create Registry Entry in Vista ... Pin
Sameer_Thakur4-May-07 23:33
Sameer_Thakur4-May-07 23:33 
GeneralRe: Create Registry Entry in Vista ... Pin
Manjunath S4-May-07 23:45
Manjunath S4-May-07 23:45 
GeneralRe: Create Registry Entry in Vista ... Pin
Sameer_Thakur5-May-07 0:00
Sameer_Thakur5-May-07 0:00 
GeneralRe: Create Registry Entry in Vista ... Pin
Manjunath S5-May-07 0:14
Manjunath S5-May-07 0:14 
AnswerRe: Create Registry Entry in Vista ... Pin
Michael Dunn5-May-07 7:06
sitebuilderMichael Dunn5-May-07 7:06 

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.