Anonymous
Not applicable
Mar 23, 2014
11:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 23, 2014
11:03 PM
2 Replies
Mar 24, 2014
02:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 24, 2014
02:19 AM
Hi jdbatista,
it depends on how the data is coded. If the data is always two single bytes, you can simply write the bytes to the proper positions of an int.
//write directly to the corresponding positions
unsigned int Test;
unsigned char MSB, LSB;
Test = LSB;
Test |= MSB << 8;
You can also use unions/structs to create the memory layout for the incoming data, but this depends on the situation.If the data is ASCII coded you should use atoi() functions.
Regards,
Ralf
Mar 24, 2014
03:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 24, 2014
03:52 AM
And do not forget there are the standard function famiies printf() and scanf() which allows you at both ends to convert your variables to formatted strings and back. have a look here: publications.gbdirect.co.uk/c_book/chapter9/formatted_io.html
Bob