<?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>answer | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/answer/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>Sat, 09 Jan 2021 11:28:37 +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>answer | 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 simple C Question</title>
		<link>https://learncgames.com/answer-to-simple-c-question/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=answer-to-simple-c-question</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 11 Jan 2021 00:00:42 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[answer]]></category>
		<category><![CDATA[python tutor]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2342</guid>

					<description><![CDATA[<p>Hopefully you got choice 2. 62. Here&#8217;s the question again. #include &#60;stdio.h&#62; int main() { float* p = (float*)50; p = p + 3; printf(&#34;%u\n&#34;, p); } The first line in main() creates a &#8220;pointer to a float&#8221; p with the initial value 50. This 50 is the value of p i.e. the address that [&#8230;]</p>
The post <a href="https://learncgames.com/answer-to-simple-c-question/">Answer to simple C Question</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;:257,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/geralt-9301\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1699957&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260128125116\/https:\/\/pixabay.com\/users\/geralt-9301\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 13:18:04&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 22:35:47&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-17 01:07:39&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-23 12:24:10&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 10:54:08&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-07 13:44:18&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-31 04:52:23&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-04 15:14:02&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 11:23:28&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 17:22:44&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 10:05:06&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-20 10:20:48&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 10:20:48&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:258,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1699957&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 13:18:05&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 22:35:47&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-17 01:07:40&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-23 12:24:10&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 10:54:08&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-07 13:44:17&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-31 04:52:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-04 15:14:06&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 11:23:27&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 17:22:44&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 10:05:15&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-20 10:20:46&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 10:20:46&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:259,&quot;href&quot;:&quot;http:\/\/pythontutor.com\/visualize.html#code=%23include%20%3Cstdio.h%3E%0Aint%20main%28%29%20%7B%0A%20%20%20%20float*%20p%20%3D%20%28float*%2950%3B%0A%20%20%20%20p%20%3D%20p%20%2B%203%3B%0A%20%20%20%20printf%28%22%25u%5Cn%22,%20%28unsigned%20int%29p%29%3B%0A%7D&amp;cumulative=false&amp;curInstr=4&amp;heapPrimitives=nevernest&amp;mode=display&amp;origin=opt-frontend.js&amp;py=c&amp;rawInputLstJSON=%5B%5D&amp;textReferences=false&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206132241\/https:\/\/pythontutor.com\/visualize.html&quot;,&quot;redirect_href&quot;:&quot;https:\/\/pythontutor.com\/visualize.html&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:260,&quot;href&quot;:&quot;https:\/\/docs.google.com\/document\/d\/13_Bc-l2FKMgwPx4dZb0sv7eMfYMHhRVgBRShha8kgbU\/edit#heading=h.xsw90kyed9ct&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251130104927\/https:\/\/docs.google.com\/document\/d\/13_Bc-l2FKMgwPx4dZb0sv7eMfYMHhRVgBRShha8kgbU\/edit&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 13:19:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 22:35:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 01:07:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-23 12:24:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 10:54:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-07 13:44:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-31 04:52:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-04 15:14:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-08 11:23:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-12 17:13:35&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-16 10:05:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-19 18:00:31&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 18:00:31&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2344" aria-describedby="caption-attachment-2344" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-2344" src="https://learncgames.com/wp-content/uploads/2021/01/town-sign-1699957_640-300x225.jpg" alt="Answer sign" width="300" height="225" srcset="https://learncgames.com/wp-content/uploads/2021/01/town-sign-1699957_640-300x225.jpg 300w, https://learncgames.com/wp-content/uploads/2021/01/town-sign-1699957_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2344" class="wp-caption-text">Image by <a href="https://pixabay.com/users/geralt-9301/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1699957">Gerd Altmann</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1699957">Pixabay</a></figcaption></figure>
<p>Hopefully you got choice 2. <strong>62</strong>. Here&#8217;s the question again.</p>
<pre><code class="language-c" data-line="">#include &lt;stdio.h&gt;
int main() {
	float* p = (float*)50;
	p = p + 3;
	printf(&quot;%u\n&quot;, p);
}</code></pre>
<p>The first line in main() creates a &#8220;pointer to a float&#8221; p with the initial value 50. This 50 is the value of p i.e. the address that p is pointing to, NOT the value at that address P is pointed to.</p>
<p>Adding 3 to p moves the pointer by 3 x the size of a float. As it&#8217;s unspecified, this size of a float is typically 32-bits or 4 bytes. So this line adds 12 to p. It now has the value 62.</p>
<p>You can try this out and step through it on the<a title="Link to Python Tutor with C program." href="http://pythontutor.com/visualize.html#code=%23include%20%3Cstdio.h%3E%0Aint%20main%28%29%20%7B%0A%20%20%20%20float*%20p%20%3D%20%28float*%2950%3B%0A%20%20%20%20p%20%3D%20p%20%2B%203%3B%0A%20%20%20%20printf%28%22%25u%5Cn%22,%20%28unsigned%20int%29p%29%3B%0A%7D&amp;cumulative=false&amp;curInstr=4&amp;heapPrimitives=nevernest&amp;mode=display&amp;origin=opt-frontend.js&amp;py=c&amp;rawInputLstJSON=%5B%5D&amp;textReferences=false" target="_blank" rel="nofollow noopener"> Python Tutor</a>. Despite its name, it will let you run run programs in Python, C, C++, Java, JavaScript, TypeScript and Ruby. It compiles C with GCC 4.8 and uses a Valgrind Memcheck plugin. There are <a title="Link to Python tutor restrictions document" href="https://docs.google.com/document/d/13_Bc-l2FKMgwPx4dZb0sv7eMfYMHhRVgBRShha8kgbU/edit#heading=h.xsw90kyed9ct" target="_blank" rel="nofollow noopener">a few restrictions</a> its quite a nice way to show off execution of simple programs.</p>The post <a href="https://learncgames.com/answer-to-simple-c-question/">Answer to simple C Question</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">2342</post-id>	</item>
	</channel>
</rss>
