Click here to Skip to main content
16,006,535 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: some questions about cursor Pin
gggwb13-Jan-08 15:51
gggwb13-Jan-08 15:51 
GeneralRe: some questions about cursor Pin
Iain Clarke, Warrior Programmer13-Jan-08 23:57
Iain Clarke, Warrior Programmer13-Jan-08 23:57 
GeneralRe: some questions about cursor Pin
followait14-Jan-08 0:55
followait14-Jan-08 0:55 
GeneralQuestion about using #include in a #define Pin
ioctl5113-Jan-08 1:56
ioctl5113-Jan-08 1:56 
GeneralRe: #include in a #define Pin
Luc Pattyn13-Jan-08 2:02
sitebuilderLuc Pattyn13-Jan-08 2:02 
GeneralRe: Question about using #include in a #define Pin
CPallini13-Jan-08 2:16
mveCPallini13-Jan-08 2:16 
GeneralRe: Question about using #include in a #define Pin
zengkun10013-Jan-08 2:35
zengkun10013-Jan-08 2:35 
GeneralSerialize / De-Serialize struct to Buffer Pin
_NielsB12-Jan-08 23:56
_NielsB12-Jan-08 23:56 
Well, another beginner issue from me.
I want to serialize several structs to a char array.
In the end, the char* should point to smth like this: <b1><b2>
Finnaly, i want to de-serialize the B2 from this array to a new B2_dupe;

The problem: with my code, B2_dupe is not filled correctly.

If you dont mind, please have a look at the following code-
<br />
#pragma pack(1)<br />
struct A<br />
{<br />
  A(){<br />
	Sig1 = 'A';<br />
	Sig2 = 'B';<br />
	Sig3 = 'C';<br />
	Version = '1';<br />
	Numbers = 2;<br />
	Reserved = 0;<br />
	Offset = 0;<br />
   }<br />
   char Sig1;<br />
   char Sig2;<br />
   char Sig3;<br />
   char Version;<br />
   char Numbers:7;<br />
   char Reserved:1;<br />
   unsigned long Offset; <br />
};<br />
<br />
struct B<br />
{<br />
   B(){<br />
	Id=0;<br />
	Reserved=0;<br />
	Offset=0;}<br />
   char Id:7;<br />
   char Reserved:1;<br />
   long Offset;<br />
};<br />
<br />
#pragma pack()<br />
<br />
// calc size<br />
int sizeA = sizeof A;<br />
int sizeB = sizeof B;<br />
	<br />
// struct A<br />
A a;<br />
a.Sig1 = 'D';<br />
<br />
// struct B #1<br />
B b1;<br />
b1.Id = 0;<br />
b1.Offset = 0;<br />
	<br />
// struct B #2<br />
B b2;<br />
b2.Id = 1;<br />
b2.Offset = 0;<br />
		<br />
// serialize	<br />
int nSizeSer = (2*sizeB)+sizeA;<br />
char* pBuff = new char[nSizeSer];<br />
memcpy(pBuff, &a, sizeA);<br />
memcpy(pBuff+sizeA, &b1, sizeB);<br />
memcpy(pBuff+sizeB, &b2, sizeB);<br />
<br />
// de-serialize<br />
B b2_dupe;<br />
int offset = sizeA+sizeB;<br />
pBuff+=offset; //move ptr<br />
memcpy(&b2_dupe,pBuff,sizeB);<br />
<br />


I checked b2_dupe.Offset and this should be zero ... but it isnt (-842150451).
Why is that?

Thanks in advance Smile | :)

GeneralRe: Serialize / De-Serialize struct to Buffer Pin
CPallini13-Jan-08 1:44
mveCPallini13-Jan-08 1:44 
GeneralRe: Serialize / De-Serialize struct to Buffer Pin
_NielsB13-Jan-08 1:46
_NielsB13-Jan-08 1:46 
Generalusing task manager to monitor memory Pin
George_George12-Jan-08 23:01
George_George12-Jan-08 23:01 
GeneralRe: using task manager to monitor memory Pin
Hamid_RT13-Jan-08 0:50
Hamid_RT13-Jan-08 0:50 
GeneralRe: using task manager to monitor memory Pin
George_George13-Jan-08 2:35
George_George13-Jan-08 2:35 
GeneralRe: using task manager to monitor memory Pin
Hamid_RT13-Jan-08 3:54
Hamid_RT13-Jan-08 3:54 
GeneralRe: using task manager to monitor memory Pin
George_George13-Jan-08 4:05
George_George13-Jan-08 4:05 
GeneralRe: using task manager to monitor memory Pin
Hamid_RT14-Jan-08 18:28
Hamid_RT14-Jan-08 18:28 
GeneralRe: using task manager to monitor memory Pin
George_George14-Jan-08 18:40
George_George14-Jan-08 18:40 
GeneralRe: using task manager to monitor memory Pin
Hamid_RT14-Jan-08 19:05
Hamid_RT14-Jan-08 19:05 
GeneralRe: using task manager to monitor memory Pin
George_George14-Jan-08 19:56
George_George14-Jan-08 19:56 
GeneralRe: using task manager to monitor memory Pin
Hamid_RT14-Jan-08 20:36
Hamid_RT14-Jan-08 20:36 
Generalnew and VirtualAlloc Pin
George_George12-Jan-08 21:42
George_George12-Jan-08 21:42 
GeneralRe: new and VirtualAlloc Pin
CPallini13-Jan-08 1:39
mveCPallini13-Jan-08 1:39 
GeneralRe: new and VirtualAlloc Pin
George_George13-Jan-08 2:39
George_George13-Jan-08 2:39 
GeneralRe: new and VirtualAlloc Pin
zengkun10013-Jan-08 4:20
zengkun10013-Jan-08 4:20 
GeneralRe: new and VirtualAlloc Pin
George_George13-Jan-08 16:32
George_George13-Jan-08 16:32 

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.