Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,558 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,935 people online right now. Registration is fast and FREE... Join Now!




Storing a Union element into a structure

 
Reply to this topicStart new topic

Storing a Union element into a structure

boschow
11 Apr, 2008 - 05:37 AM
Post #1

New D.I.C Head
*

Joined: 7 May, 2007
Posts: 41


My Contributions
Hi again,
I am programing in C language and here is my problem. Lets say that I have a lot of unions like the one declared in the example below:

CODE

typedef union {
struct {
unsigned GS_GS_OF_BS:1;
unsigned GS_AM_BC:1;
unsigned GS_F_BC:1;
unsigned GS_GS_HRR_BC:1;
unsigned GS_GS_M_BC:1;
unsigned GS_GS_OF_BC:1;
unsigned GS_GS_RA_BC:1;
unsigned GS_GS_RAB_BC:1;
}bit; UINT8 all;
}GS_Coils;



From these large amount of unions I want to store the UINT8 all variables in a separate structure.

CODE

GS_Coils *X;
typedef struct { X->all; . . . }All_Coils;



From here on I will use a function to pass all the elements of the structure All_Coils to an array UINT8 buffer[512]. And this array will be send through a network connection.

Thanks and best regards,
BoSCHoW.
User is offlineProfile CardPM
+Quote Post

jeronimo0d0a
RE: Storing A Union Element Into A Structure
11 Apr, 2008 - 07:00 AM
Post #2

D.I.C Head
**

Joined: 3 Mar, 2008
Posts: 141


My Contributions
Not quite sure I understand the question. why can't you
GS_Coils coil_array[512] ;
and store the coils there?
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Storing A Union Element Into A Structure
11 Apr, 2008 - 04:12 PM
Post #3

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 50 times
Dream Kudos: 550
My Contributions
I have no idea what you are trying to ask.
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 11:28PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month