<?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>answers | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/answers/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Mon, 15 Feb 2021 20:18:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>answers | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Answer to the C Puzzle</title>
		<link>https://learncgames.com/answer-to-the-c-puzzle/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=answer-to-the-c-puzzle</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 18 Feb 2021 00:00:04 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[answers]]></category>
		<category><![CDATA[puzzle]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2696</guid>

					<description><![CDATA[<p>If you look back at the puzzle, you might think the for loop is a bit odd starting at -1 and that&#8217;s the snag. It exits the for loop immediately because -1 is actually more than 5. It&#8217;s a rather subtle bug. The type of d is obviously int, but the type of (TOTAL_ELEMENTS &#8211; [&#8230;]</p>
The post <a href="https://learncgames.com/answer-to-the-c-puzzle/">Answer to the C Puzzle</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:167,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/absolutvision-6158753\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2636254&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251202005902\/https:\/\/pixabay.com\/users\/absolutvision-6158753\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:22:55&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-13 18:38:53&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-17 08:07:24&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-25 23:09:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-06 23:28:36&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 01:58:02&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-22 13:45:27&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-22 13:45:27&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:168,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2636254&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:22:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-13 18:38:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-17 08:07:24&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-25 23:09:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-06 23:28:36&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 01:57:59&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-19 07:31:05&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-22 13:45:26&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-22 13:45:26&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2697" aria-describedby="caption-attachment-2697" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-2697" src="https://learncgames.com/wp-content/uploads/2021/02/solve-2636254_640-300x168.jpg" alt="Solution" width="300" height="168" srcset="https://learncgames.com/wp-content/uploads/2021/02/solve-2636254_640-300x168.jpg 300w, https://learncgames.com/wp-content/uploads/2021/02/solve-2636254_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2697" class="wp-caption-text">Image by <a href="https://pixabay.com/users/absolutvision-6158753/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2636254">Gino Crescoli</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2636254">Pixabay</a></figcaption></figure>
<p>If you look back at <a title="Link to fc puzzle" href="https://learncgames.com/a-little-c-puzzle/" target="_blank" rel="nofollow noopener">the puzzle</a>, you might think the for loop is a bit odd starting at -1 and that&#8217;s the snag. It exits the for loop immediately because -1 is actually more than 5. It&#8217;s a rather subtle bug. The type of d is obviously <strong>int</strong>, but the type of (TOTAL_ELEMENTS &#8211; 2) is <strong>unsigned int</strong>.</p>
<p>So what I believe is happening is the compiler is promoting d to an unsigned int which is 4294967295, and clearly that&#8217;s a bit larger than 5. To fix this just put (int) before the (TOTAL_ELEMENTS &#8211; 2) in the for loop and it will work.</p>The post <a href="https://learncgames.com/answer-to-the-c-puzzle/">Answer to the C Puzzle</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2696</post-id>	</item>
	</channel>
</rss>
