CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

struct convert char viceversa

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
salviador
Guest







struct convert char viceversa
PostPosted: Mon Mar 02, 2009 3:40 am     Reply with quote

Hi,

I've a structure:
Code:

struct _alarm {
   float temp1_Temp;
   int8  temp1_dir;
   float temp2_Temp;
   int8  temp2_dir;
   float volt_volt;
   int8  volt_dir;
   float amp_amp;
   int8  amp_dir;
};
struct _alarm alarm;
char buffer[50];

If I'd like copy the struct in char buffer and viceversa in the elegant mode with use typecast

How I do?
Ttelmah
Guest







PostPosted: Mon Mar 02, 2009 5:39 am     Reply with quote

Easiest, don't.
Just use a union.
That way the data doesn't have to move.
If you must move it, then use the memcpy function.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group