<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: 5.1 &#8212; Control flow introduction</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/</link>
	<description></description>
	<pubDate>Wed, 20 Aug 2008 08:51:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Learn C++ - &#187; 4.7 &#8212; Structs</title>
		<link>http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-13463</link>
		<dc:creator>Learn C++ - &#187; 4.7 &#8212; Structs</dc:creator>
		<pubDate>Tue, 29 Apr 2008 04:45:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-13463</guid>
		<description>[...] 2007      Prev/Next Posts   &#171; What Google giveth, Google taketh away&#8230; &#124; Home &#124; 5.1 &#8212; Control flow introduction &#187;     Wednesday, June 20th, 2007 at 6:34 [...]</description>
		<content:encoded><![CDATA[<p>[...] 2007      Prev/Next Posts   &laquo; What Google giveth, Google taketh away&#8230; | Home | 5.1 &#8212; Control flow introduction &raquo;     Wednesday, June 20th, 2007 at 6:34 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-9545</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 13 Mar 2008 21:18:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-9545</guid>
		<description>exit() will cause the program to terminate immediately, regardless of where it is called.

One thing you'll need to be careful of when using exit is to make sure you do any necessary cleanup before the program exits.  Most of the time, no explicit cleanup is needed.  However, it's probably a good idea to close any open file handles, network sockets, etc... before exiting.  Note that destructors to in-scope variables will not be called before the program exits.</description>
		<content:encoded><![CDATA[<p>exit() will cause the program to terminate immediately, regardless of where it is called.</p>
<p>One thing you&#8217;ll need to be careful of when using exit is to make sure you do any necessary cleanup before the program exits.  Most of the time, no explicit cleanup is needed.  However, it&#8217;s probably a good idea to close any open file handles, network sockets, etc&#8230; before exiting.  Note that destructors to in-scope variables will not be called before the program exits.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-9528</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Thu, 13 Mar 2008 16:19:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-9528</guid>
		<description>Alex, what is the difference, if any, between using a "halt":

&lt;pre&gt;if (bIsError1)
    exit(-1);&lt;/pre&gt;

As opposed to using a standard "return" type of statement:

&lt;pre&gt;if (bIsError2)
    return -1;&lt;/pre&gt;

I'm sure I have written and compiled code before that has multiple return statements, to be executed under various conditions, within the same main().  Is there a reason to favor one type of statement over the other?


UPDATE: I may have partially answered my own question.  If exit() is called within a function other than main() does the program terminate outright rather than returning control to main()?  Side-effects?  Any other reasons to use, or not use, exit()?</description>
		<content:encoded><![CDATA[<p>Alex, what is the difference, if any, between using a &#8220;halt&#8221;:</p>
<pre>if (bIsError1)
    exit(-1);</pre>
<p>As opposed to using a standard &#8220;return&#8221; type of statement:</p>
<pre>if (bIsError2)
    return -1;</pre>
<p>I&#8217;m sure I have written and compiled code before that has multiple return statements, to be executed under various conditions, within the same main().  Is there a reason to favor one type of statement over the other?</p>
<p>UPDATE: I may have partially answered my own question.  If exit() is called within a function other than main() does the program terminate outright rather than returning control to main()?  Side-effects?  Any other reasons to use, or not use, exit()?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-8433</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Sun, 24 Feb 2008 23:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-8433</guid>
		<description>You are correct!  I meant to say "while a given condition is true", but I think it reads even better as "until a given condition is false".  Thanks for noticing!</description>
		<content:encoded><![CDATA[<p>You are correct!  I meant to say &#8220;while a given condition is true&#8221;, but I think it reads even better as &#8220;until a given condition is false&#8221;.  Thanks for noticing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen01</title>
		<link>http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-8426</link>
		<dc:creator>Allen01</dc:creator>
		<pubDate>Sun, 24 Feb 2008 20:55:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/51-control-flow-introduction/#comment-8426</guid>
		<description>Shouldn't the statement below read that the program will repeatedly execute a series of statements until a given condition is false?


Loops

A loop causes the program to repeatedly execute a series of statements until a given condition is true. 
</description>
		<content:encoded><![CDATA[<p>Shouldn&#8217;t the statement below read that the program will repeatedly execute a series of statements until a given condition is false?</p>
<p>Loops</p>
<p>A loop causes the program to repeatedly execute a series of statements until a given condition is true.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
