<?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>question | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/category/question/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>Fri, 12 Feb 2021 11:06:53 +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>question | 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>A little C Puzzle</title>
		<link>https://learncgames.com/a-little-c-puzzle/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-little-c-puzzle</link>
					<comments>https://learncgames.com/a-little-c-puzzle/#comments</comments>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 15 Feb 2021 00:00:30 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[puzzle]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2667</guid>

					<description><![CDATA[<p>The following C program doesn&#8217;t output anything. Why? #include&#60;stdio.h&#62; #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0])) int array[] = { 23,34,12,17,204,99,16 }; int main() { int d; for (d = -1; d &#60;= (TOTAL_ELEMENTS - 2); d++) printf(&#34;%d\n&#34;, array[d + 1]); return 0; } &#160; This came from this site by Gowri Kumar which has a lot [&#8230;]</p>
The post <a href="https://learncgames.com/a-little-c-puzzle/">A little 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;:172,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/gdj-1086657\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1751308&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205100514\/https:\/\/pixabay.com\/users\/gdj-1086657\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:30:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 02:18:23&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-25 04:42:44&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-22 09:12:30&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 01:45:32&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:26&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 08:23:34&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 00:13:33&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-19 07:31:05&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 07:31:05&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:173,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1751308&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:30:59&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 22:35:45&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-24 01:06:55&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 10:54:03&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-10 00:03:52&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-22 09:12:30&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 01:45:32&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:07&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 08:23:35&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 00:13:31&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-19 07:31:05&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 07:31:05&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:174,&quot;href&quot;:&quot;http:\/\/www.gowrikumar.com\/c\/index.php&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250605072906\/http:\/\/www.gowrikumar.com\/c\/index.php&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:31:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 22:35:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-25 04:42:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 09:12:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 01:45:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-31 04:52:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-04 15:14:06&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 08:23:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-16 00:13:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-19 07:31:06&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 07:31:06&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2668" aria-describedby="caption-attachment-2668" style="width: 182px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-2668" src="https://learncgames.com/wp-content/uploads/2021/02/question-mark-1751308_640-1-182x300.png" alt="Question mark" width="182" height="300" srcset="https://learncgames.com/wp-content/uploads/2021/02/question-mark-1751308_640-1-182x300.png 182w, https://learncgames.com/wp-content/uploads/2021/02/question-mark-1751308_640-1.png 389w" sizes="(max-width: 182px) 100vw, 182px" /><figcaption id="caption-attachment-2668" class="wp-caption-text">Image by <a href="https://pixabay.com/users/gdj-1086657/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1751308">Gordon Johnson</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1751308">Pixabay</a></figcaption></figure>
<p>The following C program doesn&#8217;t output anything. Why?</p>
<pre><code class="language-c" data-line="">#include&lt;stdio.h&gt;

#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = { 23,34,12,17,204,99,16 };

int main()
{
    int d;

    for (d = -1; d &lt;= (TOTAL_ELEMENTS - 2); d++)
        printf(&quot;%d\n&quot;, array[d + 1]);

    return 0;
}</code></pre>
<p>&nbsp;</p>
<p>This came from <a title="Link to C puzzle page" href="http://www.gowrikumar.com/c/index.php" target="_blank" rel="nofollow noopener">this site</a> by Gowri Kumar which has a lot more C puzzles. Answer in a day or two&#8230;</p>The post <a href="https://learncgames.com/a-little-c-puzzle/">A little C Puzzle</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://learncgames.com/a-little-c-puzzle/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2667</post-id>	</item>
		<item>
		<title>So someone wanted to know how to go about creating a dating sim</title>
		<link>https://learncgames.com/so-someone-wanted-to-know-how-to-go-about-creating-a-dating-sim/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=so-someone-wanted-to-know-how-to-go-about-creating-a-dating-sim</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Fri, 22 Jan 2021 00:00:33 +0000</pubDate>
				<category><![CDATA[design]]></category>
		<category><![CDATA[engines]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[ren'py]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2474</guid>

					<description><![CDATA[<p>This was a question in the reddit gamedev subreddit. Here&#8217;s my answer. &#8220;Think about how you might make it work as a roleplaying game. You&#8217;d have a set of characteristics- age, cuteness, physical attraction, charisma, boldness etc. Have your characters roll 3 6 sided dice to get these. Then you can work out an easy [&#8230;]</p>
The post <a href="https://learncgames.com/so-someone-wanted-to-know-how-to-go-about-creating-a-dating-sim/">So someone wanted to know how to go about creating a dating sim</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;:237,&quot;href&quot;:&quot;https:\/\/www.reddit.com\/r\/gamedev\/comments\/l0ze6o\/im_wondering_how_to_make_a_dating_sim&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:238,&quot;href&quot;:&quot;https:\/\/www.renpy.org&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206025729\/https:\/\/www.renpy.org\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 13:02:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 03:29:39&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-14 20:11:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 15:23:21&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-23 23:08:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 10:54:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-02 22:22:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-05 23:20:20&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-10 21:20:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-14 16:16:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 20:31:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 23:44:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-27 19:29:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 02:50:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-05 15:22:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-09 08:16:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-13 08:22:03&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-17 02:08:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 08:26:51&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 08:26:51&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img decoding="async" class="alignleft size-medium wp-image-2475" src="https://learncgames.com/wp-content/uploads/2021/01/Wikipe-tan_visual_novel_RenPy-300x225.png" alt="Wikipedia Ren'Py image" width="300" height="225" srcset="https://learncgames.com/wp-content/uploads/2021/01/Wikipe-tan_visual_novel_RenPy-300x225.png 300w, https://learncgames.com/wp-content/uploads/2021/01/Wikipe-tan_visual_novel_RenPy.png 640w" sizes="(max-width: 300px) 100vw, 300px" />This was a question in the reddit <a title="Link to question in reddit gamedev subreddit" href="https://www.reddit.com/r/gamedev/comments/l0ze6o/im_wondering_how_to_make_a_dating_sim/" target="_blank" rel="nofollow noopener">gamedev subreddit</a>.</p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM">Here&#8217;s my answer. <em>&#8220;Think about how you might make it work as a roleplaying game. You&#8217;d have a set of characteristics- age, cuteness, physical attraction, charisma, boldness etc. Have your characters roll 3 6 sided dice to get these. Then you can work out an easy scoring system by comparing similar characteristics.</em></p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM"><em>So once you have a basic matching algorithm, your game has to let the player find potential dates. In the gym, supermarket, dating site, college etc. Perhaps you get an initial idea about someone you meet and then you get multiple dialogs where you try and figure out how to ask them out. Choose the wrong phrase (e.g. &#8220;Do you spit or swallow?&#8221; ) and you won&#8217;t see them for dust. Maybe if the person you are asking out has a large personality they&#8217;ll laugh at your humour and say yes.</em></p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM"><em>Then you have to decide what wins the game. Getting to first base, 2nd, breakfast? Or you get a low score when they tell you they&#8217;ve decided to become a nun because of you&#8230;</em></p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM"><em>How you implement it is entirely up to you? Things like renpy, or maybe you&#8217;ll do the whole thing. For the possible target market I think you might have to make it graphical. Perhaps a comic-book type approach? That way you don&#8217;t need too many drawn backgrounds.&#8221;</em></p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM">This is the kind of thing you might use Renpy for. What is Ren&#8217;py? <a title="Link to Ren'py" href="https://www.renpy.org/" target="_blank" rel="nofollow noopener">Ren&#8217;Py</a> is a visual novel engine used by thousands of creators around the world that helps you use words, images, and sounds to tell interactive stories on computers and mobile devices. These can be both visual novels and life simulation games.</p>
<p>I got the screenshot from Wikipedia. Talk about breaking the fourth wall! And yes Ren&#8217;py has an irritating apostrophe in the middle!</p>The post <a href="https://learncgames.com/so-someone-wanted-to-know-how-to-go-about-creating-a-dating-sim/">So someone wanted to know how to go about creating a dating sim</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">2474</post-id>	</item>
		<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 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>
		<item>
		<title>Simple C question</title>
		<link>https://learncgames.com/simple-c-question/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-c-question</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 10 Jan 2021 00:00:51 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[programming question]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2339</guid>

					<description><![CDATA[<p>I saw this this morning and got the correct answer. I also tried it just to be sure in Visual Studio and apart from a warning, it compiled ok and ran and gave the correct answer. #include &#60;stdio.h&#62; int main() { float* p = (float*)50; p = p + 3; printf(&#34;%u\n&#34;, p); } If you [&#8230;]</p>
The post <a href="https://learncgames.com/simple-c-question/">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;:263,&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=2110767&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:20: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:39&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-20 14:22:39&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:16&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-31 04:52:25&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-04 15:14:08&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:13:34&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 10:05:12&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-19 18:00:18&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 18:00:18&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:264,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2110767&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:20:07&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 22:35:46&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-20 14:22:40&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:24&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-04 15:14:03&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 11:23:26&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 17:13:34&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 10:05:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 04:08:12&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 04:08:12&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2340" aria-describedby="caption-attachment-2340" style="width: 300px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-medium wp-image-2340" src="https://learncgames.com/wp-content/uploads/2021/01/question-mark-2110767_640-300x200.jpg" alt="question marks" width="300" height="200" srcset="https://learncgames.com/wp-content/uploads/2021/01/question-mark-2110767_640-300x200.jpg 300w, https://learncgames.com/wp-content/uploads/2021/01/question-mark-2110767_640.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2340" 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=2110767">Gerd Altmann</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2110767">Pixabay</a></figcaption></figure>
<p>I saw this this morning and got the correct answer. I also tried it just to be sure in Visual Studio and apart from a warning, it compiled ok and ran and gave the correct answer.</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>If you want to avoid the warning, change the last line to</p>
<pre><code class="language-c" data-line="">	printf(&quot;%u\n&quot;, (unsigned int)p);</code></pre>
<p>So the question is what does this output?</p>
<ol>
<li>53</li>
<li>62</li>
<li>66</li>
<li>68</li>
</ol>
<p>Answer and explanation tomorrow.</p>The post <a href="https://learncgames.com/simple-c-question/">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">2339</post-id>	</item>
	</channel>
</rss>
