From: Goh Yong Kwang Newsgroups: comp.os.msdos.djgpp Subject: How to convert an unsigned short into a 2 char array? Date: Mon, 12 Oct 1998 09:45:10 +0800 Organization: Ngee Ann Polytechnic, Singapore Lines: 18 Message-ID: NNTP-Posting-Host: mercury.np.ac.sg Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII NNTP-Posting-User: s6606555 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com How do I convert an unsigned short (2 bytes) into a 2 char array? Does the following code does the trick? ----------------------------------- char array[2]; unsigned short s = 123; // Initialize it to some sample value first. array |= s; // OR the bits to copy bit pattern into array. // Maybe some casting needs to be done. ----------------------------------- ---------------------------------- Many regards, Goh Yong Kwang 96606555 3K ----------------------------------