<?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>loop | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/loop/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>Thu, 11 Jun 2020 19:32:51 +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>loop | 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>Goto is considered bad programming in C but</title>
		<link>https://learncgames.com/goto-is-considered-bad-programming-in-c-but/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=goto-is-considered-bad-programming-in-c-but</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 15 Jun 2020 23:00:37 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[goto]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[nested]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=818</guid>

					<description><![CDATA[<p>There is one case for using goto when you have nested loops and you&#8217;d like to jump all the way out. The goto statement was very popular in BASIC but often resulted in programs being like spaghetti with gotos all over the place. Here&#8217;s a contrived example where I have used a goto. #include &#60;stdio.h&#62; [&#8230;]</p>
The post <a href="https://learncgames.com/goto-is-considered-bad-programming-in-c-but/">Goto is considered bad programming in C but</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignleft size-medium wp-image-819" src="https://learncgames.com/wp-content/uploads/2020/06/goto-sign-300x148.png" alt="goto exit sign" width="300" height="148" srcset="https://learncgames.com/wp-content/uploads/2020/06/goto-sign-300x148.png 300w, https://learncgames.com/wp-content/uploads/2020/06/goto-sign.png 504w" sizes="(max-width: 300px) 100vw, 300px" />There is one case for using goto when you have nested loops and you&#8217;d like to jump all the way out. The goto statement was very popular in BASIC but often resulted in programs being like spaghetti with gotos all over the place.</p>
<p>Here&#8217;s a contrived example where I have used a goto.</p>
<pre><code class="language-c" data-line="">#include &lt;stdio.h&gt; 

int array[10][10][10];
int main() {
    // Populate array
    for (int y=0;y&lt;10;y++)
      for (int x=0;x&lt;10;x++) 
        for (int z=0;z&lt;10;z++) {
          if (array[x][y][z]==0)
            goto exit;
    }
exit:;
}</code></pre>
<p>In my C programs, for-loops are the most popular followed by while-loops, do-while loops and gotos are hardly ever used at all.</p>The post <a href="https://learncgames.com/goto-is-considered-bad-programming-in-c-but/">Goto is considered bad programming in C but</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">818</post-id>	</item>
	</channel>
</rss>
