473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Copy structures

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.

--
David Buck
2D CAD for RISC OS at www.risccad.freeuk.com
Nov 23 '05 #1
2 5051
David Buck wrote:
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 !

--
David Buck
2D CAD for RISC OS at www.risccad.freeuk.com
Nov 23 '05 #2
David Buck wrote:
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.

--
Chris "another virtual machine" Dollin
missing tests don't fail.
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: laclac01 | last post by:
I have developed my own copy function for coping my own dynamic memory structure. It works, but I feel its not too efficient. There must be a quicker way to copy the data. In some of the...
2
by: Alex | last post by:
Entering the following in the Python shell yields >>> help(dict.copy) Help on method_descriptor: copy(...) D.copy() -> a shallow copy of D >>>
3
by: Leo Nunez | last post by:
Hello! I need copy from structure "A" to "B" that contains "strings" in a one line code. Me problem like this : typedef struct tHeader{ char field1; char field2; char field3;
9
by: Michael | last post by:
Hi all, I want to copy a structure, but the only thing I have is a pointer to it. Whats good here? Because the structure contains no pointers, but arrays and variables I thought of doing a...
8
by: Jesper | last post by:
Hi, Does the concept "copy constructor" from c++ excist in c#. What is the syntax. best regards Jesper.
4
by: Dennis | last post by:
I have several Data Structures, say "mystruct" which contain arrays of bytes, other structures, etc. I then dimension a variable (var1) as "mystruct" and set the various elements var1 to data. I...
7
by: pallav | last post by:
I'm having some trouble with my copy constructor. I've tried using gdb to find the bug, but it seg faults in the destructor. I'm not able to see what I'm doing wrong. Since I'm using pointers, I...
8
by: anon.asdf | last post by:
Hi! OK, lets try "array-copy": { char arrayA; arrayA = (char){1, 2, 3}; } it does *not* work since we're trying to make a fixed array-pointer arrayA, point to another location/address...
7
by: pereges | last post by:
which one do you think is better ? I need to make my program efficient and in some places I have passed the copy of a variable which makes life some what easy while writing huge expressions but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.