<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Tue May 21, 2013 4:20 am by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Tue May 21, 2013 4:20 am</pubDate>
  <lastBuildDate>Tue May 21, 2013 4:20 am</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27741#27741</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5530'&gt;GMorgan&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Jul 19, 2006 3:38 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      &lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;alloydog wrote:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;quote&quot;&gt;I'm glad you explained that.&lt;br /&gt;
&lt;br /&gt;
Last time I tired it, all I got was a &lt;span style=&quot;font-style: italic&quot;&gt;psuedorandom&lt;/span&gt; sequence!&lt;br /&gt;
&lt;br /&gt;
I give it a bash again.&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Another trick. Because srand takes an integer as an argument and integers are limited in size (4 bytes on most machines, lets call it MAX) it leaves you with only a limited number of combinations for your random numbers. to get away from this when you have a discreet set of items like say a pack of cards use the number generator to shuffle them rather than place them.&lt;br /&gt;
&lt;br /&gt;
It has several benefits because first of all placing a pack of cards via random number generation has a problem with indefinite postponement where it could take a millisecond or it could take 5 minutes to shuffle the pack, reshuffling doesn't have this problem. Also with reshuffling the number of posible outcomes goes up as a power of the posible outputs of rand for every shuffle you make so the first shuffle gives MAX posible packs while the second shuffle gives MAX*MAX and the third MAX*MAX*MAX etc.&lt;br /&gt;
&lt;br /&gt;
Anyway to do this first time fill a 52 card array (in order if need be) then take a loop for 0 &amp;lt; x &amp;lt; 51 then generate a random number y between 0 and 51 for every pass of the loop. Simply swap the values in the array at x and y.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27741#27741</comments>
                                        <author>GMorgan</author>
                                        <pubDate>Wed Jul 19, 2006 3:38 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27741#27741</guid>
                                      </item>
                                      <item>
                                        <title>RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27707#27707</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=133'&gt;jjmac&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jul 18, 2006 11:33 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      alloydog wrote:&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
sorry, never meant to come across rude...&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
twasn't taken as such &lt;img src=&quot;images/smiles/icon_smile.gif&quot; alt=&quot;Smile&quot; border=&quot;0&quot; /&gt;,&lt;br /&gt;
&lt;br /&gt;
As above though, it can be very hard to put something together, if it isn't already known. Some sought of example, template will always be needed. Unless you happen to be RMS of course (grin). Pretty much all that is drawn up will be sourced/templated/extended from previous works. So, once the particular function set has been acquired, then the relevant headers naturally follow.&lt;br /&gt;
&lt;br /&gt;
A person doesn't have to limit themselves to C++ examples/templates to write up a C++ expression. Other language units can also be useful.. They will likely be using the same basic functions and logic flow. Pascal units can be helpful there.&lt;br /&gt;
&lt;br /&gt;
The mention of B Eckels (i always spell that name wrong) &quot;Tthinking in C++&quot; is a really good tutorial. His stuff on Java is also worth while too.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
Yeah, I know I could just web-search &quot;random number generator c++&quot; but that doesn't teach me anything,&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I would have to disagree with that &lt;img src=&quot;images/smiles/icon_smile.gif&quot; alt=&quot;Smile&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
jm</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27707#27707</comments>
                                        <author>jjmac</author>
                                        <pubDate>Tue Jul 18, 2006 11:33 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27707#27707</guid>
                                      </item>
                                      <item>
                                        <title>RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27704#27704</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=127'&gt;alloydog&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jul 18, 2006 11:02 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I'm glad you explained that.&lt;br /&gt;
&lt;br /&gt;
Last time I tired it, all I got was a &lt;span style=&quot;font-style: italic&quot;&gt;psuedorandom&lt;/span&gt; sequence!&lt;br /&gt;
&lt;br /&gt;
I give it a bash again.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27704#27704</comments>
                                        <author>alloydog</author>
                                        <pubDate>Tue Jul 18, 2006 11:02 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27704#27704</guid>
                                      </item>
                                      <item>
                                        <title>RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27703#27703</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5530'&gt;GMorgan&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jul 18, 2006 10:52 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      For random numbers you use the rand() and srand() functions. You need the &amp;lt;cstdlib&amp;gt; library header to use them. Basically to get a random number between 0 and RAND_MAX (where RAND_MAX is at least 32767) enter&lt;br /&gt;
&lt;br /&gt;
x = rand();&lt;br /&gt;
where x is an integer.&lt;br /&gt;
&lt;br /&gt;
The srand function allows you to seed the random number generator (this is crucial otherwise your random numbers will always be the same). This works like this&lt;br /&gt;
&lt;br /&gt;
srand( y );&lt;br /&gt;
again y is an integer. &lt;br /&gt;
&lt;br /&gt;
Generally you see people calling the srand function with the time function. This gives the appreance of randomness because very few people in history could percieve the link between the time and the numbers generated. To use the time function you must add the &amp;lt;ctime&amp;gt; library header. It works like this.&lt;br /&gt;
&lt;br /&gt;
srand ( time( NULL ) );&lt;br /&gt;
&lt;br /&gt;
Be sure to set this at least once in your program but you can use it several times depending on how your program is to work. If you are doing some kind of modelling then each time the model runs a new seeding is probably a good idea. Once you've seeded the generator what you actually get is a series of predetermined but apparently random numbers and the rand() function just outputs them one at a time.&lt;br /&gt;
&lt;br /&gt;
One last thing. To generate a number between a certain range use this equation&lt;br /&gt;
&lt;br /&gt;
x = m + rand() % n;&lt;br /&gt;
&lt;br /&gt;
where the range is m &amp;lt; (m + n - 1). Hope this helps.&lt;br /&gt;
&lt;br /&gt;
Last time I checked 'C++ programming tutorials' gives 2m results, you can't have tried them all &lt;img src=&quot;images/smiles/icon_wink.gif&quot; alt=&quot;Wink&quot; border=&quot;0&quot; /&gt; . One resource I picked up which is quite complete is thinking in C++ volumes 1 and 2, you can pick them up on PDF for free.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27703#27703</comments>
                                        <author>GMorgan</author>
                                        <pubDate>Tue Jul 18, 2006 10:52 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27703#27703</guid>
                                      </item>
                                      <item>
                                        <title>RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27685#27685</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=127'&gt;alloydog&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jul 18, 2006 7:27 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      sorry, never meant to come across rude... &lt;img src=&quot;images/smiles/icon_redface.gif&quot; alt=&quot;Embarassed&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
I was wondering, for example, if I tried to write a random number generator, say a &quot;simple&quot; die programme, other than &lt;span style=&quot;font-weight: bold&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt; how would I know which, if any other headers to use?&lt;br /&gt;
&lt;br /&gt;
Yeah, I know I could just web-search &quot;random number generator c++&quot; but that doesn't teach me anything, besides th eusefulness of search engines, that is &lt;img src=&quot;images/smiles/icon_wink.gif&quot; alt=&quot;Wink&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
I never though of the man pages - RTFM!</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27685#27685</comments>
                                        <author>alloydog</author>
                                        <pubDate>Tue Jul 18, 2006 7:27 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27685#27685</guid>
                                      </item>
                                      <item>
                                        <title>RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27647#27647</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=133'&gt;jjmac&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jul 18, 2006 10:09 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      &amp;gt;&amp;gt;&lt;br /&gt;
Hmm, doesn't help... &lt;br /&gt;
&lt;br /&gt;
What I mean is, if you're learning C++, how do you know which headers to use?&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sorry it didn't help. As for the second part, the various examples that a person may come accross will generally have the relavent headers stated. If not, looking the function up in a 'man' page will show the particular header concerned.&lt;br /&gt;
&lt;br /&gt;
What i was trying to say though, was that the main focus is with the function. Your thought on approching it via a header list isn't really neccessary. And you will find it isn't the approach that is taken. It is possible that the header could change, though, also unlikely at the same time. But, as it is possible, the function itself is the better thing to look at. While its' interface and structure may change, its' purpose wont. So the relevant header will also be stated in any discusion on the function itself.&lt;br /&gt;
&lt;br /&gt;
All the headers in /usr/include/C++/&amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
are worth looking into.&lt;br /&gt;
&lt;br /&gt;
You should find things like &amp;lt;cstdlib&amp;gt;, &amp;lt;cstdio&amp;gt;, &amp;lt;iostream&amp;gt; etc will be commonly needed by most programs. As will the statement ...&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
placed up the top of each source file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
jm</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27647#27647</comments>
                                        <author>jjmac</author>
                                        <pubDate>Tue Jul 18, 2006 10:09 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27647#27647</guid>
                                      </item>
                                      <item>
                                        <title>RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27645#27645</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=127'&gt;alloydog&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jul 18, 2006 9:49 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hmm, doesn't help...&lt;br /&gt;
&lt;br /&gt;
What I mean is, if you're learning C++, how do you know which headers to use?&lt;br /&gt;
&lt;br /&gt;
Most beginniers tutorials only cover a few, with &lt;span style=&quot;font-weight: bold&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt; being the most common.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27645#27645</comments>
                                        <author>alloydog</author>
                                        <pubDate>Tue Jul 18, 2006 9:49 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27645#27645</guid>
                                      </item>
                                      <item>
                                        <title>RE: Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27642#27642</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=133'&gt;jjmac&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jul 18, 2006 9:25 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I doubt if gcc.org would have such a list. I think the approach to explanation/description is via the functions themselves rather than the header there declared/defined in. Possibly suggesting that the header isn't a static document. And so could change over time. The function may change in it's form, but it's purpose is likely not to. Just a thought.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
jm</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27642#27642</comments>
                                        <author>jjmac</author>
                                        <pubDate>Tue Jul 18, 2006 9:25 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27642#27642</guid>
                                      </item>
                                      <item>
                                        <title>Standard ANSI C++ header files</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=27632#27632</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=127'&gt;alloydog&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Mon Jul 17, 2006 11:18 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I have been trying to find a detailed list of the standard ANSI C++ header files (&lt;span style=&quot;font-weight: bold&quot;&gt;&amp;lt;algorithm&amp;gt; &amp;lt;iomanip&amp;gt; &amp;lt;list&amp;gt; &amp;lt;queue&amp;gt;&lt;/span&gt; and so on).&lt;br /&gt;
&lt;br /&gt;
I found several lists, but none explain what each file does and where you would/could/should use it.  I have even looked at the ANSI home site, but with no luck.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=27632#27632</comments>
                                        <author>alloydog</author>
                                        <pubDate>Mon Jul 17, 2006 11:18 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=27632#27632</guid>
                                      </item></channel></rss>