<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: ascii code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 07 Oct 2008 18:46:41 GMT</pubDate>
    <description>DZone Snippets: ascii code</description>
    <item>
      <title>c C++ convert hex to ascii</title>
      <link>http://snippets.dzone.com/posts/show/2073</link>
      <description>// Presented with hex such as 0x12345abc perhaps there is a spot in there&lt;br /&gt;// which represents an ascii char - such as 53 would be 'S'&lt;br /&gt;// Common when dealing with hardware-related data structures and wire&lt;br /&gt;// protocols&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;*	To convert 53 to the character 'S':&lt;br /&gt;*	char returnVal = hexToString('5', '3');&lt;br /&gt;*/&lt;br /&gt;char hexToAscii(char first, char second)&lt;br /&gt;{&lt;br /&gt;	char hex[5], *stop;&lt;br /&gt;	hex[0] = '0';&lt;br /&gt;	hex[1] = 'x';&lt;br /&gt;	hex[2] = first;&lt;br /&gt;	hex[3] = second;&lt;br /&gt;	hex[4] = 0;&lt;br /&gt;	return strtol(hex, &amp;stop, 16);&lt;br /&gt;}&lt;br /&gt;int main(int argc, char* argv[])&lt;br /&gt;{&lt;br /&gt;	printf("%c\n", hexToAscii('5', '3'));&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;produces this output:&lt;br /&gt;S</description>
      <pubDate>Thu, 18 May 2006 20:37:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2073</guid>
      <author>ocorpening (Owen Corpening)</author>
    </item>
  </channel>
</rss>
