Copy structures

D

David Buck

I have a structure as follows;

typedef struct {
char queue[24];
unsigned int mode;
unsigned int baud;
unsigned int data;
BOOL del;
} cblock

I create two data structures

cblock real;
cblock dlog;

the idea being that the dlog structure takes a copy of the real structure
when a dialogue box opens, to allow the user to play with various settings,
and then copies these temporary settings back to real when the user clicks
OK.

Can I copy the data before opening the dialogue with

dlog = real;

and copy it back after with

real=dlog;

it all seems to work, except the real.queue and dlog.queue don't copy
correctly.
 
D

David Buck

David said:
I have a structure as follows;

typedef struct {
char queue[24];
unsigned int mode;
unsigned int baud;
unsigned int data;
BOOL del;
} cblock

I create two data structures

cblock real;
cblock dlog;

the idea being that the dlog structure takes a copy of the real
structure when a dialogue box opens, to allow the user to play with
various settings, and then copies these temporary settings back to
real when the user clicks OK.

Can I copy the data before opening the dialogue with

dlog = real;

and copy it back after with

real=dlog;

it all seems to work, except the real.queue and dlog.queue don't copy
correctly.

Apologies, found the error. It does work, just not my brain !
 
C

Chris Dollin

David said:
I have a structure as follows;

typedef struct {
char queue[24];
unsigned int mode;
unsigned int baud;
unsigned int data;
BOOL del;
} cblock

I create two data structures

cblock real;
cblock dlog;

the idea being that the dlog structure takes a copy of the real structure
when a dialogue box opens, to allow the user to play with various
settings, and then copies these temporary settings back to real when the
user clicks OK.

Can I copy the data before opening the dialogue with

dlog = real;

and copy it back after with

real=dlog;
Yes.

it all seems to work, except the real.queue and dlog.queue don't copy
correctly.

How do you know?

Minimal complete example, please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,475
Latest member
NovellaSce

Latest Threads

Top