<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Infrequently Asked Questions in comp.lang.c</title>
		<link>http://www.allegro.cc/forums/view/262904</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 29 Apr 2003 04:28:30 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just a bit of fun this - the comp.lang.c IAQ (Infrequently Asked Questions).</p><p>[url <a href="http://www.plethora.net/~seebs/faqs/c-iaq.html">http://www.plethora.net/~seebs/faqs/c-iaq.html</a>]</p><p><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /></p><p>AE.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Andrei Ellman)</author>
		<pubDate>Mon, 28 Apr 2003 03:18:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Some of those are pretty funny. Now, anyway.<br />When I was first learning C though, that page would have been helpful! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Derezo)</author>
		<pubDate>Mon, 28 Apr 2003 04:07:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I'm dumb!!</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>10.7: Can I declare main as void, to shut off these annoying ``main returns no value&#039;&#039; messages? (I&#039;m calling exit(), so main doesn&#039;t return.)</p><p>Certainly. You can also declare it as double. It may not compile, or it may crash, but who cares? No lousy bunch of whining lusers is going to tell <b>you</b> what to do. </p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Mon, 28 Apr 2003 15:02:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
2.3: How does struct passing and returning work? <br />The structures are put into the low part of the VGA card&#039;s VRAM. They are then removed before the next video update. This is why struct passing was not supported for a long time; VGA cards were prohibitively expensive. </p><p>If you try to pass very large structures on the stack, you may see odd screen graphics.
</p></div></div><p>

So that&#039;s why my app wasn&#039;t working properly! <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Mon, 28 Apr 2003 17:02:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, good. Just what I need to fend off the newbs. Andrei, I love you. <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Perry)</author>
		<pubDate>Mon, 28 Apr 2003 19:07:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p><b>1.6: I finally figured out the syntax for declaring pointers to functions, but now how do I initialize one?</b></p><p>With the assignment operator. You were perhaps expecting a screwdriver?</p></div></div><p>Heh <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p><b>1.8: What&#039;s the auto keyword good for?</b></p><p>Declaring vehicles.</p></div></div><p>Ha! In C++ we can build vehicle objects from scratch! C++ IS T3H B357357!!11`1</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p><b>2.10: Can I initialize unions?</b></p><p>Depends. They may go on strike when provoked. Luckily, if your program involves air traffic control, the ISO standard guarantees that Ronald Reagan will fire any unions that go on strike, and replace them with structs, which should be close enough.</p></div></div><p><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Mon, 28 Apr 2003 19:11:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">23yrold3yrold said:</div><div class="quote"><p>Ha! In C++ we can build vehicle objects from scratch!</p></div></div><p>Reinvent the wheel, why don&#039;t you. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p><b>runs</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Perry)</author>
		<pubDate>Mon, 28 Apr 2003 19:17:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
<b>runs down BP in his CTank: public CMilitaryVehicle: public CVehicle: public CAuto</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Mon, 28 Apr 2003 19:23:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A public military vehicle? What is the world coming to?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trumgottist)</author>
		<pubDate>Mon, 28 Apr 2003 21:19:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My favourite so far:</p><p>&quot;<b>5.9: How would I initialize an entire array from standard input?</b></p><p>You have to use a loop. For instance, the following code reads the numbers zero through 99 into the array a.</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">for</span> <span class="k2">(</span>i <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> i <span class="k3">&lt;</span> <span class="n">100</span><span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>i<span class="k2">)</span>
        a<span class="k3">&lt;</span>i&gt; <span class="k3">=</span> <span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_670.html" target="_blank">scanf</a>, <span class="k2">(</span><span class="s">"%d"</span>, i<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Make sure to include &lt;stdio.h&gt;, or this may not work.&quot;</p><p><img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Perry)</author>
		<pubDate>Mon, 28 Apr 2003 22:32:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ummm... That&#039;s just nonsense. <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Irrelevant)</author>
		<pubDate>Mon, 28 Apr 2003 23:08:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No. That code works. Try it. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Perry)</author>
		<pubDate>Mon, 28 Apr 2003 23:27:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Actually, no. IIRC, scanf returns the number of successfully assigned values, not the values themselves. So it would be an array of a hundred one&#039;s.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Mon, 28 Apr 2003 23:30:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Exactly.  Nyah. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>It couldn&#039;t return the vals themselves, because then what would it return from:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> foo<span class="k2">;</span>
<span class="k1">float</span> bar<span class="k2">;</span>
<a href="http://www.delorie.com/djgpp/doc/libc/libc_670.html" target="_blank">scanf</a><span class="k2">(</span><span class="s">"%i%f"</span>, <span class="k3">&amp;</span>foo, <span class="k3">&amp;</span>bar<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
Anyway, even if it <b>did</b> return the values, every loop it would ask you for a number and reset i.</p><p>...and you&#039;d also get a typecasting error (from <b>int</b> to &lt;b&gt;int ). <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>As I said, it&#039;s nonsense.  S&#039;got too many holes.</p><p>It&#039;s still funny, though. <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Irrelevant)</author>
		<pubDate>Tue, 29 Apr 2003 00:05:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><i>&quot;and reset i.&quot;</i><br />No, if you entered 99, it would stop the loop, if you entered &lt;99, it would keep going.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Tue, 29 Apr 2003 01:12:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Note the spare comma and then see the note on that FAQ entry.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trumgottist)</author>
		<pubDate>Tue, 29 Apr 2003 01:15:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k1">for</span> <span class="k2">(</span>i <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> i <span class="k3">&lt;</span> <span class="n">100</span><span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>i<span class="k2">)</span>
        a<span class="k3">&lt;</span>i&gt; <span class="k3">=</span> <span class="k2">(</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_670.html" target="_blank">scanf</a>, <span class="k2">(</span><span class="s">"%d"</span>, i<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>
is equal to
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">for</span> <span class="k2">(</span>i <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> i <span class="k3">&lt;</span> <span class="n">100</span><span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>i<span class="k2">)</span>
        a<span class="k3">&lt;</span>i&gt; <span class="k3">=</span> i<span class="k2">;</span>
</pre></div></div><p>

read the code, Luke.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (spellcaster)</author>
		<pubDate>Tue, 29 Apr 2003 01:22:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Whoops. Missed the comma. <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" /></p><p>That&#039;s messed up; someone want to explain to me what&#039;s going on there?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Tue, 29 Apr 2003 01:23:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What&#039;s the problem?<br />scanf is called, the return value is discarded. &quot;%d&quot; is just a string and would return itself, if there woudln&#039;t be yet another comma which makes sure that i is returned.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (spellcaster)</author>
		<pubDate>Tue, 29 Apr 2003 01:26:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>...and you&#039;d also get a typecasting error (from int to int *). <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p></div></div><p>No you wouldn&#039;t. It&#039;s one of the optional arguments, so a plain ANSI C compiler will just take its type at face value (after doing some promotions like char,short-&gt;int and float-&gt;double). GCC will warn if you want, because it knows how scanf and similar functions are supposed to work. However, it won&#039;t do any conversions; it would be violating the ANSI C standard if it did.</p><p>Don&#039;t worry guys, I didn&#039;t get it straight away either. I had to read the note too. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>OK, here&#039;s the deal. scanf is NOT called; all that happens is the code takes a pointer to scanf. When you get a comma, the left-hand expression is evaluated first and discarded (useful if it has a side-effect), and then the right-hand expression is evaluated. The whole expression has the value of the right-hand subexpression. Likewise, the &quot;%d&quot; (actually a pointer to such a string stored in read-only memory) is discarded, and the i is returned.</p><p>So, give or take a couple of &#039;left-hand blah of comma has no effect&#039; warnings (not an accurate quote <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /> ), it compiles and does exactly what it says on the tin. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>PWNED. <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Bruce Perry)</author>
		<pubDate>Tue, 29 Apr 2003 03:36:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Glad everyone seems to be enjoying the C IAQ.;D</p><p>After a bit of Googling around, I have found some IAQs for some other languages.</p><ul><li><p><a href="http://www.slack.net/~shiva/iaq.html">C++</a></p></li><li><p><a href="http://perl.plover.com/IAQ/IAQlist.html">Perl</a></p></li></ul><p>
The following are also IAQs, but these are more serious than the above two.
</p><ul><li><p><a href="http://www.norvig.com/java-iaq.html">Java</a></p></li><li><p><a href="http://www.seas.gwu.edu/~simhaweb/java/faq/faq.html">Java (again)</a></p></li><li><p><a href="http://www.norvig.com/python-iaq.html">Python</a></p></li><li><p><a href="http://burks.brighton.ac.uk/burks/language/objc/iaq/iaq.htm">Objective C</a></p></li></ul><p>

Enjoy.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Andrei Ellman)</author>
		<pubDate>Tue, 29 Apr 2003 04:08:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Bah. the perl one is somewhat lame... but I like th atoi subroutine <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><div class="source-code snippet"><div class="inner"><pre><span class="p"># Q: How do I convert a string to a number?</span>
<span class="p"># A: Use this atoi function:</span>

        sub <a href="http://www.delorie.com/djgpp/doc/libc/libc_54.html" target="_blank">atoi</a> <span class="k2">{</span>
          my $t<span class="k2">;</span>
          foreach my $d <span class="k2">(</span>split<span class="k2">(</span><span class="c">//, shift())) {</span>
            $t <span class="k3">=</span> $t <span class="k3">*</span> <span class="n">10</span> <span class="k3">+</span> $d<span class="k2">;</span>
          <span class="k2">}</span>
        <span class="k2">}</span>
 
        $number <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_54.html" target="_blank">atoi</a><span class="k2">(</span><span class="s">"123"</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Or: </p><div class="source-code snippet"><div class="inner"><pre><span class="p"># Q: How do I get the length of a variable?</span>
<span class="p"># A: Use</span>
        length<span class="k2">(</span><span class="s">'$variable'</span><span class="k2">)</span><span class="k2">;</span>
<span class="p"># to find out how long a variable is.</span>
</pre></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Q: Can I get a YACC grammar for the Perl language?<br />A: Sorry, but as you must surely be aware by now, the only animals supported by Perl are ruminants such as camels and llamas. However, Yacc support may be forthcoming with version 5.007.</p><p>Q: What are all those $@%* signs for?<br />A: Watch your $@*$!% mouth, buddy!</p></div></div><p>

Ok Ok.. The ones near the end are pretty good... But the first few are totally lame.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Q: How do I block warnings?<br />A: The simplest way is to do:<br />        close STDERR;</p></div></div><p>

</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Q: How can I find out whether a number is odd?<br /> A:<br />        sub odd {<br />            my $number = shift;<br />            return !even ($number);<br />        } </p><p>Q: How can I find out whether a number is even?<br />A:<br />        sub even {<br />            my $number = abs shift;<br />            return 1 if $number == 0;<br />            return odd ($number - 1);<br />        }</p></div></div><p>
Those are good <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /></p><p><img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /> </p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Q: Perldoc isn&#039;t running properly. Where can I find the documentation?<br />A:<br />        perldoc perldoc</p></div></div><p>

Ok.. the next one is just bad. Funny. But just wrong. </p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>Q: What&#039;s the difference between single quoted strings and double quoted strings?<br />A: Single quoted strings act like q(); double quoted strings act like qq().</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 29 Apr 2003 04:19:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>scanf is NOT called</p></div></div><p>That&#039;s what I thought; Spellcaster confused me <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (23yrold3yrold)</author>
		<pubDate>Tue, 29 Apr 2003 04:28:30 +0000</pubDate>
	</item>
</rss>
