copying a short int to a char array

Posted by cateof on Stack Overflow See other posts from Stack Overflow or by cateof
Published on 2010-06-01T20:01:51Z Indexed on 2010/06/01 20:13 UTC
Read the original article Hit count: 272

Filed under:
|
|

I have a short integer variable called s_int that holds value = 2

unsighed short s_int = 2;

I want to copy this number to a char array to the first and second position of a char array.

Let's say we have char buffer[10];. We want the two bytes of s_int to be copied at buffer[0] and buffer[1].

How can I do it?

© Stack Overflow or respective owner

Related posts about c++

Related posts about c