<?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>oscarbonilla.com &#187; C</title>
	<atom:link href="http://oscarbonilla.com/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://oscarbonilla.com</link>
	<description></description>
	<lastBuildDate>Thu, 15 Dec 2011 18:43:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Another useless C99 tidbit</title>
		<link>http://oscarbonilla.com/2008/04/another-useless-c99-tidbit/</link>
		<comments>http://oscarbonilla.com/2008/04/another-useless-c99-tidbit/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 06:50:04 +0000</pubDate>
		<dc:creator>ob</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://blog.oscarbonilla.com/?p=64</guid>
		<description><![CDATA[Another useless C99 tidbit: trigraphs.]]></description>
			<content:encoded><![CDATA[<p>From page 18 of the <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf">C99</a> standard:</p>
<blockquote><p>
All occurrences in a source ﬁle of the following sequences of three characters (called trigraph sequences) are replaced with the corresponding single character. </p>
<pre>
??= #    ??( [     ??/ \
??) ]      ??' ^     ??< {
??! |      ??> }    ??- ~
</pre>
<p>No other trigraph sequences exist. Each ? that does not begin one of the trigraphs listed above is not changed.
</p></blockquote>
<p>Ok, so take the following C program:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">??=</span>include <span style="color: #339933;">&lt;</span>stdio.<span style="color: #202020;">h</span><span style="color: #339933;">&gt;</span>
<span style="color: #993333;">int</span>
main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #339933;">??</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">??</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">??&lt;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;hello world<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">??&gt;</span></pre></div></div>

<p>And compile it with the <code>-trigraphs</code> switch to gcc:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">dirac src $ gcc -trigraphs -o trigraphs trigraphs.c
dirac src $ ./trigraphs
hello world</pre></div></div>

<p>Combined with <a href="http://blog.oscarbonilla.com/2008/04/11/hidden-gems-in-c99-1/">this</a> you could seriously obfuscate your C code.</p>
]]></content:encoded>
			<wfw:commentRss>http://oscarbonilla.com/2008/04/another-useless-c99-tidbit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

