<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>You are not welcome in my world! &#187; char to int</title>
	<atom:link href="http://blog.ayberkyilmaz.net/tag/char-to-int/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ayberkyilmaz.net</link>
	<description>things that matter</description>
	<lastBuildDate>Fri, 18 Feb 2011 23:34:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Char to Int Conversion in C</title>
		<link>http://blog.ayberkyilmaz.net/2010/char-to-int-conversion-in-c-101</link>
		<comments>http://blog.ayberkyilmaz.net/2010/char-to-int-conversion-in-c-101#comments</comments>
		<pubDate>Thu, 01 Jul 2010 21:01:44 +0000</pubDate>
		<dc:creator>Ayberk Yılmaz</dc:creator>
				<category><![CDATA[Teknik]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[char to int]]></category>
		<category><![CDATA[char to int conversion]]></category>

		<guid isPermaLink="false">http://blog.ayberkyilmaz.net/?p=101</guid>
		<description><![CDATA[The programming thing has a lot of tricks and as a programmer, I like them very very much. The latest trick that i have come across is converting a char digit to its integer value. As you know, if you write something like this: char num[11] = "0123456789"; int s = (int)num[0]; printf("%d\n",s); It will [...]]]></description>
			<content:encoded><![CDATA[<p>The programming thing has a lot of tricks and as a programmer, I like them very very much.</p>
<p>The latest trick that i have come across is converting a char digit to its integer value.</p>
<p>As you know, if you write something like this:</p>
<p><code>char num[11] = "0123456789";<br />
int s = (int)num[0];<br />
printf("%d\n",s);</code></p>
<p>It will not print 0, but instead it will print the <a href="http://www.asciitable.com">ASCII</a> value of &#8217;0&#8242;.</p>
<p>While looking for a quick solution, I have seen this perfect trick at stackoverflow:</p>
<p><code>char num[11] = "0123456789";<br />
int s = num[0] - '0';<br />
printf("%d\n",s);</code></p>
<p>Since all the digits are consecutive at the ASCII Table, -supposing all the elements are digits- substracting the ASCII value of &#8217;0&#8242; from that digit&#8217;s ASCII value gives you the correct integer value of the digit.</p>
<p>All that I can say is: FASCINATING!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ayberkyilmaz.net/2010/char-to-int-conversion-in-c-101/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

