<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>C++ Feed - Programmer's Heaven</title>
    <link>http://www.programmersheaven.com/feed/Tag/1278/RSS.aspx</link>
    <description>Events at Programmer's Heaven related to C++.</description>
    <language>en</language>
    <copyright>Copyright 2009 Programmers Heaven</copyright>
    <pubDate>Fri, 20 Nov 2009 21:03:44 -0700</pubDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <item>
      <title>Re: initializing static array</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/409653/409654/ReadMessage.aspx#409654</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bsaucer/"&gt;bsaucer&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/409653/409654/ReadMessage.aspx#409654"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;Let mne clarify what I mean by "static". I mean that the array is a static member of the class.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/409653/409654/ReadMessage.aspx#409654</guid>
      <pubDate>Fri, 20 Nov 2009 12:37:40 -0700</pubDate>
    </item>
    <item>
      <title>initializing static array</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/409653/409653/ReadMessage.aspx#409653</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bsaucer/"&gt;bsaucer&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/409653/409653/ReadMessage.aspx#409653"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;I am writing a class which will have a static array. I need to initialize the array using a for loop. There will be several instances of the class, each of which will read values from the array. The instances need to treat the array as "constant". The code to initialize the array needs to be executed only once, not once for each instance.&lt;br /&gt;
&lt;br /&gt;
Can I do all of this, and what is the syntax? &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/409653/409653/ReadMessage.aspx#409653</guid>
      <pubDate>Fri, 20 Nov 2009 12:24:07 -0700</pubDate>
    </item>
    <item>
      <title>Re:  three one dimensional arrays</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/409328/409558/ReadMessage.aspx#409558</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/pseudocoder/"&gt;pseudocoder&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/409328/409558/ReadMessage.aspx#409558"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;I'd encourage you to get rid of the numerical input using scanf and instead, use a char array, fgets, and sscanf to store the variables.  As your program is now, it will get loopy should a user enter an alpha or punct character instead of a number.&lt;br /&gt;
&lt;br /&gt;
I changed a few things... hopefully, it will compile and do what you need it to do. :)&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include &amp;lt;stdio.h&amp;gt;

#define MAX_NUM 10

int main(void) {

   int Quantity[MAX_NUM] = { 0 };  
   int Price[MAX_NUM] = { 0 };
   int i;
   float Amount[MAX_NUM] = { 0.0f };    
    
   for (i = 0; i &amp;lt; MAX_NUM; i++) {
      printf("Quantity");
      scanf("%d", &amp;amp;Quantity[i]);         
   }   
   
   for (i = 0; i &amp;lt; MAX_NUM; i++) {
       printf("Price: ");
       scanf("%d", &amp;amp;Price[i]);
   }
  
   for (i = 0; i &amp;lt; MAX_NUM; i++) {
       printf("Price %d = %d\n", i, Price[i]);
       Amount[i] = (float)Quantity[i] * Price[i];
   }

   printf("%9s%9s%9s\n----------------------------\n\n", 
          "Quantity", "Price", "Amount");

   for (i = 0; i &amp;lt; MAX_NUM; i++)   
      printf("%#7d%#7d%#12.2f\n", Quantity[i], Price[i], Amount[i]);
   
   while(getchar() != '\n'){}
   
   return 0;
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
HTH</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/409328/409558/ReadMessage.aspx#409558</guid>
      <pubDate>Thu, 19 Nov 2009 00:18:59 -0700</pubDate>
    </item>
    <item>
      <title>Re: Erasing White Spaces</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/409321/409466/ReadMessage.aspx#409466</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/Gabe/"&gt;Gabe&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/409321/409466/ReadMessage.aspx#409466"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Hi!&lt;br /&gt;
&lt;br /&gt;
Turn off &lt;strong&gt;skipws&lt;/strong&gt; flag on in_stream because it'll automatically omit whitespace characters from input stream:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;in_stream.unsetf(ifstream::skipws);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Then create a loop and a boolean varibale to remember if the previous character was a whitespace or not. If you encounter a non-whitespace character then there're two possibilities:&lt;br /&gt;
&lt;br /&gt;
1) The previous character was a whitespace (your boolean variable is true) then output &lt;strong&gt;one&lt;/strong&gt; space and the actual character then set the boolean variable to false.&lt;br /&gt;
&lt;br /&gt;
2) The previous character was a non-whitespace (your boolean variable is false) then output the actual character.&lt;br /&gt;
&lt;br /&gt;
Some sample code:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
   // Clear skipws flag on in_stream
   in_stream.unsetf(ifstream::skipws);
   
   bool        prev_ws = false;

   while(!in_stream.eof()) {
      char        ch;
      in_stream &amp;gt;&amp;gt; ch;

      if(ch == ' ' || ch == '\t')
         prev_ws = true;

      else {
         if(prev_ws == true)
            cout &amp;lt;&amp;lt; ' ';
         prev_ws = false;
         cout &amp;lt;&amp;lt; ch;
      }
   }
&lt;/pre&gt;&lt;br /&gt;
I've considered both '&lt;strong&gt;\r&lt;/strong&gt;' and '&lt;strong&gt;\n&lt;/strong&gt;' as non-whitespace characters to keep the line structure of the file intact.&lt;br /&gt;
&lt;br /&gt;
Hope this helps!&lt;br /&gt;
&lt;br /&gt;
Cheers,&lt;br /&gt;
   Gabe</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/409321/409466/ReadMessage.aspx#409466</guid>
      <pubDate>Tue, 17 Nov 2009 12:09:31 -0700</pubDate>
    </item>
    <item>
      <title>Re: Effective tool for run-time errors and memory leaks detection</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/409421/409443/ReadMessage.aspx#409443</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/409421/409443/ReadMessage.aspx#409443"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;Call this function just before your main() returns:&lt;br /&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/d41t22sb(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/d41t22sb(VS.80).aspx&lt;/a&gt;&lt;br /&gt;
&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/409421/409443/ReadMessage.aspx#409443</guid>
      <pubDate>Tue, 17 Nov 2009 05:22:36 -0700</pubDate>
    </item>
    <item>
      <title>Re: help with strings</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/409416/409442/ReadMessage.aspx#409442</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/409416/409442/ReadMessage.aspx#409442"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;If you have a linked list - binary search will not be effective, because it requires that collection be accessed with an index and linked list does not have that ability. You need an array here.&lt;br /&gt;
&lt;br /&gt;
Once you have an array filled and sorted - you should be able to use binary search. In callback function for a search you need to check not the whole string, but only its prefix - it should be easy enough.&lt;br /&gt;
&lt;br /&gt;
And binary search will only give you the answer - if the prefix found or not. The full list of words starting with the prefix you will find using the found index. Go up the array (from index returned by BS) and find where the group of words begins (at which index), then go down the array (from index returned by BS) and find the end of the group.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/409416/409442/ReadMessage.aspx#409442</guid>
      <pubDate>Tue, 17 Nov 2009 05:18:06 -0700</pubDate>
    </item>
    <item>
      <title>Re: Chess program</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/409361/409365/ReadMessage.aspx#409365</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/409361/409365/ReadMessage.aspx#409365"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;You need a 2D array representing a chess board. Next, you need functions (yes! functions are easy!) to work with the board: put a piece on the cell or check the state of a cell, using its coordinates: row, column.&lt;br /&gt;
&lt;br /&gt;
For example: if you have a KNIGHT at ROW=4 COLUMN=2, then you need to apply the offsets for KNIGHT jump (and you need to do it 8 times, well you should know the steps for a KNIGHT). The same example - one of KNIGHT steps is shift 2 rows up and 1 column to the right - that means you need to ADD these offsets to the KNIGHT location and check the resulting cell for 1) is that cell OFF the board? and 2) is a WHITE KING there? You need to do same checks for each chess piece according to the laws of the game.&lt;br /&gt;
&lt;br /&gt;
The simple model of the board would be a 2D array:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;int board [8][8];
int row = 5;
int col = 4;
int cell = board [row][col]; // or is it board[col][row]?.. not sure&lt;/pre&gt;&lt;br /&gt;
&lt;span style="color: Blue;"&gt;Just my opinion: that task is not a beginner task.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/409361/409365/ReadMessage.aspx#409365</guid>
      <pubDate>Mon, 16 Nov 2009 05:00:34 -0700</pubDate>
    </item>
    <item>
      <title>Re: VC++ Build  Error</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/409206/409282/ReadMessage.aspx#409282</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/409206/409282/ReadMessage.aspx#409282"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;This is actually a Run-Time error, not a Build error. When you see the assertion box - press 'Debug' button on it and check the code (stack trace it back to your code).&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/409206/409282/ReadMessage.aspx#409282</guid>
      <pubDate>Sat, 14 Nov 2009 05:20:15 -0700</pubDate>
    </item>
    <item>
      <title>Re: C double variable takes up too much space</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/409124/409281/ReadMessage.aspx#409281</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/409124/409281/ReadMessage.aspx#409281"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;The proper size of any variable is taken with sizeof() operator and not by calculating address difference:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
double value;
printf ("\nType 'double' takes %d bytes for storage.\n", sizeof (value));
&lt;/pre&gt;&lt;span style="color: Blue;"&gt;The results you seeing are the effect of stack alignment - stack must be aligned on 8 or 16 byte frame. If variables on stack are crossing these boundaries - the storage room is aligned for:&lt;br /&gt;
&lt;br /&gt;
1. Performance - aligned variables are faster to access by CPU&lt;br /&gt;
2. Stack room in general (see Intel Manuals) must be aligned, otherwise program will crash.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/409124/409281/ReadMessage.aspx#409281</guid>
      <pubDate>Sat, 14 Nov 2009 05:15:49 -0700</pubDate>
    </item>
    <item>
      <title>Re: displaying roman character equivalent to a number</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/408387/409213/ReadMessage.aspx#409213</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/vijayshankarb/"&gt;vijayshankarb&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/408387/409213/ReadMessage.aspx#409213"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;: Hello all,&lt;br /&gt;
: &lt;br /&gt;
: i came across a interesting question about displaying Roman character&lt;br /&gt;
: when the input is number.&lt;br /&gt;
: &lt;br /&gt;
: ---------------------------------------------------&lt;br /&gt;
: For example :&lt;br /&gt;
: &lt;br /&gt;
: 1	i	50	l	364	ccclxiiii&lt;br /&gt;
: 2	ii	100	c	2222	mmccxxii&lt;br /&gt;
: 5	v	500	d&lt;br /&gt;
: 7	vii	1000	m&lt;br /&gt;
: 10      x&lt;br /&gt;
: ---------------------------------------------------&lt;br /&gt;
: And to make the programming more challenging, only "getchar()" &lt;br /&gt;
: command&lt;br /&gt;
: is allowed to get input from the users.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: I somehow managed to create the code to get the input from users.&lt;br /&gt;
: For example : input : 3456 , i am able to capture "3456" n convert &lt;br /&gt;
: into integer for further processing.&lt;br /&gt;
: -----------------------------------------------&lt;br /&gt;
: printf("input ?: ");  &lt;br /&gt;
:  number = 0;&lt;br /&gt;
:  ch = getchar();&lt;br /&gt;
: &lt;br /&gt;
:  while(ch != '\n')&lt;br /&gt;
:     {&lt;br /&gt;
:      if('0' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= '9')&lt;br /&gt;
:       {&lt;br /&gt;
:        number = number * 10;&lt;br /&gt;
:        number = number + (ch - '0');&lt;br /&gt;
:       }&lt;br /&gt;
:     ch=getchar();&lt;br /&gt;
:    }&lt;br /&gt;
: -----------------------------------------------&lt;br /&gt;
: &lt;br /&gt;
: Just wondering anyone has any idea on how to convert n display&lt;br /&gt;
: Roman characters equivalent to that particular input&lt;br /&gt;
&lt;br /&gt;
It is easy if you realize a top down approach,&lt;br /&gt;
&lt;br /&gt;
ie. 3456 = (1000*3) + (500 - 100) + (50) + (5 + 1)&lt;br /&gt;
&lt;br /&gt;
struct romanInt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
    char str[3];&lt;br /&gt;
    int value;&lt;br /&gt;
}&lt;br /&gt;
romanPair[] ={&lt;br /&gt;
{"", 0},{"I" ,1},{"IV",4}, {"V", 5}, {"IX",9}, {"X",10}, {"XL",40},{"L", 50},{"XC", 90},{"C", 100}, {"CD",400}, {"D", 500}, {"CM", 900},{"M", 1000}&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    char output[10];&lt;br /&gt;
    startIndex = sizeof(romanPair)/sizeof(*romanPair) - 1;&lt;br /&gt;
    output[0] = '\0';&lt;br /&gt;
    n = number; // the number u have derived&lt;br /&gt;
    while (n &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
        if (n &amp;gt;= romanPair[startIndex].value)&lt;br /&gt;
        {&lt;br /&gt;
            for (int i = 1; i &amp;lt;= n/romanPair[startIndex].value; i++)&lt;br /&gt;
            strcat(output, romanPair[startIndex].str);&lt;br /&gt;
            n %= romanPair[startIndex].value;&lt;br /&gt;
        }&lt;br /&gt;
        startIndex--;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
....</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/408387/409213/ReadMessage.aspx#409213</guid>
      <pubDate>Fri, 13 Nov 2009 03:57:28 -0700</pubDate>
    </item>
    <item>
      <title>Re: retrieving a string with spaces from a file.</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/409033/409051/ReadMessage.aspx#409051</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/409033/409051/ReadMessage.aspx#409051"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;Use fgets() instead of fscanf() to get the whole iine. Then simply scan the text until first digit is met.&lt;br /&gt;
&lt;br /&gt;
Also, try the %20s format for first parameter, because the requirement says something about first 20 characters being a name.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/409033/409051/ReadMessage.aspx#409051</guid>
      <pubDate>Tue, 10 Nov 2009 18:45:04 -0700</pubDate>
    </item>
    <item>
      <title>Re: unable to create output file</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/408952/408970/ReadMessage.aspx#408970</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/408952/408970/ReadMessage.aspx#408970"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;Try to save the file NONAME.C as some PROG1.C or some other name. Turbo C assumes that NONAME is a predefined file name for a non-existent file. Change it.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/408952/408970/ReadMessage.aspx#408970</guid>
      <pubDate>Mon, 09 Nov 2009 05:03:38 -0700</pubDate>
    </item>
    <item>
      <title>Re: Symbol referencing error when compiling</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/408878/408969/ReadMessage.aspx#408969</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/408878/408969/ReadMessage.aspx#408969"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;That is because "EXIT" and "exit" are different in C language. Use "exit" in place of "EXIT".&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/408878/408969/ReadMessage.aspx#408969</guid>
      <pubDate>Mon, 09 Nov 2009 04:59:23 -0700</pubDate>
    </item>
    <item>
      <title>Help needed !! ( displaying roman character )</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/408942/408942/ReadMessage.aspx#408942</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/spurs01/"&gt;spurs01&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/408942/408942/ReadMessage.aspx#408942"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;Hello ,&lt;br /&gt;
&lt;br /&gt;
I need help on how to change user entered numerical number into Roman character.&lt;br /&gt;
&lt;br /&gt;
For example ,  1 = i , 2 = ii , 5 = v , 10 = x , 13 = xiii&lt;br /&gt;
&lt;br /&gt;
I have done the programming half way and do not know how to continue&lt;br /&gt;
from 11 onward.&lt;br /&gt;
&lt;br /&gt;
Please advice !!!&lt;br /&gt;
---------------------------------------------------------------------&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int romanize(int q, int base, char letter)&lt;br /&gt;
{&lt;br /&gt;
   int counter, counter2, temp, test;&lt;br /&gt;
   &lt;br /&gt;
	if(base == 1)&lt;br /&gt;
	 {&lt;br /&gt;
	 &lt;br /&gt;
	    if(q &amp;lt; 5)&lt;br /&gt;
         {&lt;br /&gt;
	      printf("Romanize character is ");&lt;br /&gt;
            for(counter = 1; counter &amp;lt;= q; counter++)&lt;br /&gt;
             {   &lt;br /&gt;
              printf("%c",letter);&lt;br /&gt;
             } &lt;br /&gt;
   	     }&lt;br /&gt;
   &lt;br /&gt;
        if(q &amp;gt;=5 &amp;amp;&amp;amp; q &amp;lt;=9)&lt;br /&gt;
         {&lt;br /&gt;
	      printf("Romanize character is v");&lt;br /&gt;
	      temp = q - 5;&lt;br /&gt;
	      for(counter = 1; counter &amp;lt;= temp; counter++)&lt;br /&gt;
	       {&lt;br /&gt;
	        printf("%c",letter);&lt;br /&gt;
	       }&lt;br /&gt;
		 }  &lt;br /&gt;
	 }&lt;br /&gt;
//-------------------------------------------------------------------------------------------&lt;br /&gt;
    if(base == 2)&lt;br /&gt;
	 {&lt;br /&gt;
	    test = q;&lt;br /&gt;
		counter = 0;&lt;br /&gt;
		counter2 = 0; &lt;br /&gt;
		&lt;br /&gt;
		 if(test &amp;lt;= 10 &amp;amp;&amp;amp; test &amp;lt;= 49)&lt;br /&gt;
         {&lt;br /&gt;
	        &lt;br /&gt;
			&lt;br /&gt;
			while( test &amp;gt;= 9 )&lt;br /&gt;
			 {&lt;br /&gt;
			  test = test - 10;&lt;br /&gt;
			  counter2++;&lt;br /&gt;
		     }&lt;br /&gt;
		    &lt;br /&gt;
			printf("inside loop is : %d\n",counter2);&lt;br /&gt;
			&lt;br /&gt;
			printf("Romanize character is ");&lt;br /&gt;
            for(counter = 1; counter &amp;lt;= counter2; counter++)&lt;br /&gt;
             {   &lt;br /&gt;
              printf("%c",letter);&lt;br /&gt;
             } &lt;br /&gt;
			 &lt;br /&gt;
		   if(test &amp;lt; 5)&lt;br /&gt;
            {&lt;br /&gt;
	          for(counter = 1; counter &amp;lt;= test; counter++)&lt;br /&gt;
               {   &lt;br /&gt;
                printf("i");&lt;br /&gt;
               } &lt;br /&gt;
   	        }&lt;br /&gt;
   &lt;br /&gt;
            if(test &amp;gt;=5 &amp;amp;&amp;amp; test &amp;lt;=9)&lt;br /&gt;
            {&lt;br /&gt;
	         printf("v");&lt;br /&gt;
	         temp = test - 5;&lt;br /&gt;
	         for(counter = 1; counter &amp;lt;= temp; counter++)&lt;br /&gt;
	         {&lt;br /&gt;
	          printf("%i");&lt;br /&gt;
	         }&lt;br /&gt;
		    }   	 &lt;br /&gt;
   	     }&lt;br /&gt;
   &lt;br /&gt;
        &lt;br /&gt;
	 }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
    int i, n, ch, number, count, intnumber[10];&lt;br /&gt;
    number = 0, count=0, i=0;&lt;br /&gt;
	&lt;br /&gt;
	printf("input ?: ");&lt;br /&gt;
    ch = getchar();&lt;br /&gt;
  &lt;br /&gt;
    while(ch!='\n')&lt;br /&gt;
     {&lt;br /&gt;
      if('0' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= '9')&lt;br /&gt;
	   {&lt;br /&gt;
	    	&lt;br /&gt;
		//This is to count the number of digit the user has enter//&lt;br /&gt;
		n = 0;&lt;br /&gt;
		n = n * 10;&lt;br /&gt;
		n = n + (ch - '0');&lt;br /&gt;
		intnumber[i] = n;//Store each entered digit into array "intnumber[]"//&lt;br /&gt;
		count++;&lt;br /&gt;
		i++;&lt;br /&gt;
		//--------------------------------------------------------//&lt;br /&gt;
		&lt;br /&gt;
		number = number * 10;&lt;br /&gt;
		number = number + (ch - '0');&lt;br /&gt;
	   }&lt;br /&gt;
	  &lt;br /&gt;
	  ch = getchar();&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
	 printf("count is %d\n",count);&lt;br /&gt;
	 printf("number is %d\n",number);&lt;br /&gt;
	 &lt;br /&gt;
	 if( count &amp;lt;= 1 ) // number is less than 10&lt;br /&gt;
	  {&lt;br /&gt;
	  romanize(number,count,'i');&lt;br /&gt;
	  }&lt;br /&gt;
	 else if( count &amp;gt; 1 ) // number is (10 &amp;lt;= number &amp;lt;=99)&lt;br /&gt;
	  {&lt;br /&gt;
	  romanize(number,count,'x');&lt;br /&gt;
      }&lt;br /&gt;
   &lt;br /&gt;
 &lt;br /&gt;
}</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/408942/408942/ReadMessage.aspx#408942</guid>
      <pubDate>Fri, 06 Nov 2009 16:01:33 -0700</pubDate>
    </item>
    <item>
      <title>Murach's C++ 2008</title>
      <link>http://www.programmersheaven.com/book/854-Murach's+C+++2008/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/benb/"&gt;benb&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/book/854-Murach's+C%2b%2b+2008/info.aspx"&gt;book&lt;/a&gt;.&lt;/p&gt;This book lets you master C++ as quickly and easily as possible by using all the time- and work-saving features of Visual Studio 2008. When you’re done, you’ll know how to use C++ 2008 to create bulletproof Windows applications like the best professionals do. You’ll know how to develop object-oriented applications using business classes, inheritance, polymorphism, interfaces, and generics the way they’re used in the real world. You’ll know how to compile, run, and enhance legacy C and native C++ code on the .NET platform. You’ll be prepared to learn more about native C++ if you should ever need to do that. And you’ll have another set of skills that will make you more valuable on the job.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/book/854-Murach's+C%2b%2b+2008/info.aspx</guid>
      <pubDate>Thu, 05 Nov 2009 12:18:39 -0700</pubDate>
    </item>
    <item>
      <title>Re: How to set maximum length for EditControl (textBox)</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/408843/408866/ReadMessage.aspx#408866</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/408843/408866/ReadMessage.aspx#408866"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;pre class="sourcecode"&gt;
BOOL &lt;span style="color: Red;"&gt;&amp;lt;your dialog class for IDD_MACHINE&amp;gt;&lt;/span&gt;::OnInitDialog ()
{
	((CEdit*) GetDlgItem (IDC_EDIT_MCNO)) -&amp;gt; LimitText (5);
	&lt;span style="color: Green;"&gt;// more of the same for rest of edit boxes...&lt;/span&gt;
	return TRUE;
}
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/408843/408866/ReadMessage.aspx#408866</guid>
      <pubDate>Thu, 05 Nov 2009 03:55:39 -0700</pubDate>
    </item>
    <item>
      <title>Re: struct queue to txt filr</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/408756/408825/ReadMessage.aspx#408825</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/408756/408825/ReadMessage.aspx#408825"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;Or you can save it into a text file, but separate the filelds with some character, which is rare for the data you are saving, like the vertical bar | character. So, basically, your structures will be saved as text lines:&lt;br /&gt;
&lt;br /&gt;
FIRST_NAME | LAST_NAME | FLOAT | INTEGER&lt;br /&gt;
=========================================&lt;br /&gt;
&lt;br /&gt;
JEROM|SMITH|87.9276|562&lt;br /&gt;
STEVEN|PACKARD|0.93843|998&lt;br /&gt;
&lt;br /&gt;
etc.&lt;br /&gt;
&lt;br /&gt;
Of course, because it takes time to format it back and forth - the binary file would be faster in terms of saving/loading, but if amount of data (# of structures) will be not large - then it should not matter. The negative side of binary file - is that you can read it easily.&lt;br /&gt;
&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/408756/408825/ReadMessage.aspx#408825</guid>
      <pubDate>Wed, 04 Nov 2009 05:30:09 -0700</pubDate>
    </item>
    <item>
      <title>displaying roman character equivalent to a number</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/408654/408654/ReadMessage.aspx#408654</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/spurs01/"&gt;spurs01&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/408654/408654/ReadMessage.aspx#408654"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt; &lt;br /&gt;
Hello all,&lt;br /&gt;
&lt;br /&gt;
Just wondering how to displaying Roman character when the input is number.&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------&lt;br /&gt;
For example :&lt;br /&gt;
&lt;br /&gt;
1 i 50 l 364 ccclxiiii&lt;br /&gt;
2 ii 100 c 2222 mmccxxii&lt;br /&gt;
5 v 500 d&lt;br /&gt;
7 vii 1000 m&lt;br /&gt;
10 x&lt;br /&gt;
---------------------------------------------------&lt;br /&gt;
And to make the programming more challenging, only "getchar()" command&lt;br /&gt;
is allowed to get input from the users.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I somehow managed to create the code to get the input from users.&lt;br /&gt;
For example : input : 3456 , i am able to capture "3456" n convert into integer for further processing.&lt;br /&gt;
-----------------------------------------------&lt;br /&gt;
printf("input ?: ");&lt;br /&gt;
number = 0;&lt;br /&gt;
ch = getchar();&lt;br /&gt;
&lt;br /&gt;
while(ch != '\n')&lt;br /&gt;
{&lt;br /&gt;
if('0' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= '9')&lt;br /&gt;
{&lt;br /&gt;
number = number * 10;&lt;br /&gt;
number = number + (ch - '0');&lt;br /&gt;
}&lt;br /&gt;
ch=getchar();&lt;br /&gt;
}&lt;br /&gt;
-----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Just wondering anyone has any idea on how to convert n display&lt;br /&gt;
Roman characters equivalent to that particular input</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/408654/408654/ReadMessage.aspx#408654</guid>
      <pubDate>Sat, 31 Oct 2009 19:15:38 -0700</pubDate>
    </item>
    <item>
      <title>Re: Sound Output from C?</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406419/408645/ReadMessage.aspx#408645</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406419/408645/ReadMessage.aspx#408645"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Is this the complete program?  Because if it is and it actually compiles then the language isn't standard C.  You would have to see that compiler's instructions to figure out how to do what you want.&lt;br /&gt;
&lt;br /&gt;
If you want to direct another program's output into a C program then you need to declare the main() so that it takes commandline arguments.&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
&lt;br /&gt;
basically argc contains the number of commandline arguments including the program's filename and **argv points to an array of C strings that list the arguments.&lt;br /&gt;
&lt;br /&gt;
Then you can redirect the other program's output from the commandline like this:&lt;br /&gt;
&lt;br /&gt;
prog &amp;gt; myCProg&lt;br /&gt;
&lt;br /&gt;
where prog is the program whose output you want to direct and myCProg is the C program.   You can also run the C program using a textfile as input to it by doing this&lt;br /&gt;
&lt;br /&gt;
myCProg &amp;lt; proglist&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406419/408645/ReadMessage.aspx#408645</guid>
      <pubDate>Sat, 31 Oct 2009 15:13:05 -0700</pubDate>
    </item>
    <item>
      <title>Re: Sound Output from C?</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406419/408418/ReadMessage.aspx#408418</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406419/408418/ReadMessage.aspx#408418"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Basically, you need look for an external C library that allows you to manipulate multimedia files.  C language in of itself does not provide support for multimedia files.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406419/408418/ReadMessage.aspx#408418</guid>
      <pubDate>Tue, 27 Oct 2009 13:05:16 -0700</pubDate>
    </item>
    <item>
      <title>Re: Converting Hex to Decimal</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/407988/408403/ReadMessage.aspx#408403</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/spurs01/"&gt;spurs01&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/407988/408403/ReadMessage.aspx#408403"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;thanx everyone !!&lt;br /&gt;
This is the final product.  Of course , it is not prefect.&lt;br /&gt;
But at least i am able to meet the requirement n submit the&lt;br /&gt;
assignment on time. haha&lt;br /&gt;
&lt;br /&gt;
thank.&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
  int decimal;&lt;br /&gt;
  int hexadecimal;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
  printf("Please enter your input in Hexadecimal form: ");&lt;br /&gt;
  &lt;br /&gt;
  decimal = 0;&lt;br /&gt;
  hexadecimal = getchar();&lt;br /&gt;
  &lt;br /&gt;
 while(hexadecimal != '\n')&lt;br /&gt;
    {&lt;br /&gt;
        if('0' &amp;lt;= hexadecimal &amp;amp;&amp;amp; hexadecimal &amp;lt;= '9')&lt;br /&gt;
         {&lt;br /&gt;
           decimal = decimal * 16;&lt;br /&gt;
           decimal = decimal + (hexadecimal - '0');&lt;br /&gt;
         }&lt;br /&gt;
        &lt;br /&gt;
        else if('A' &amp;lt;= hexadecimal &amp;amp;&amp;amp; hexadecimal &amp;lt;= 'F')&lt;br /&gt;
         {&lt;br /&gt;
           decimal = decimal * 16;&lt;br /&gt;
           decimal = decimal + (hexadecimal - 'A')+10;&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
        else if('a' &amp;lt;= hexadecimal &amp;amp;&amp;amp; hexadecimal &amp;lt;= 'f')&lt;br /&gt;
         {&lt;br /&gt;
           decimal = decimal * 16;&lt;br /&gt;
           decimal = decimal + (hexadecimal - 'a')+10;&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
        else&lt;br /&gt;
         {&lt;br /&gt;
           decimal=0;&lt;br /&gt;
           break;&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
     hexadecimal = getchar();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
  printf("your input number in decimal form is %d\n",decimal);&lt;br /&gt;
 &lt;br /&gt;
}&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/407988/408403/ReadMessage.aspx#408403</guid>
      <pubDate>Tue, 27 Oct 2009 04:59:37 -0700</pubDate>
    </item>
    <item>
      <title>Please guide me on how to get textBox values from subTabControl</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/408385/408399/ReadMessage.aspx#408399</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/408385/408399/ReadMessage.aspx#408399"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;It is not enough information about the architecture of the code. However, I can guess, that you have a few tabs in one container. One of the tabs has one edit control and the other one has another edit control. Each tab is most likely derived from CDialog. That means that resources are separate. That is important, because when you use Get/Set DlgItemText - this method works with a resource of a dialog you call it from and since you call it in the same context - one of edit controls is not found and text is not set or not received.&lt;br /&gt;
&lt;br /&gt;
The solution to this would be the architecture, where tabs can communicate with other tabs. It can be done in a lot of ways: tab can have a pointer to its container and you can 'ask' container to give you the address of other tabs, so you can send messages or call methods for these other tabs. Or it can be a simple set of global variables - global for all tabs.&lt;br /&gt;
&lt;br /&gt;
In short, your code is OK, however, the first call to GetDlgItemText is really belong in a sub tab, so you need something like below:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
&lt;span style="color: Green;"&gt;// Get text box values&lt;/span&gt;
CString MacNo_Sub;
&lt;span style="color: Red;"&gt;CDialog* pSubTab = &amp;lt;somehow, per architecture, get the sub tab pointer&amp;gt;;
pSubTab-&amp;gt;&lt;/span&gt;GetDlgItemText(IDC_EDITMCNO_SUB ,MacNo_Sub);
CString McNo_Main = MacNo_Sub;
SetDlgItemText(IDC_EDITMCNO_MAIN, McNo_Main);
&lt;/pre&gt;&lt;br /&gt;
&lt;span style="color: Blue;"&gt;If you do not know the architecture of the code, then simply set a breakpoint in a constructor of both tab dialogs in question and see how they are created - there is always a way to pass some additional information during creation.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/408385/408399/ReadMessage.aspx#408399</guid>
      <pubDate>Tue, 27 Oct 2009 04:11:33 -0700</pubDate>
    </item>
    <item>
      <title>displaying roman character equivalent to a number</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/408387/408387/ReadMessage.aspx#408387</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/spurs01/"&gt;spurs01&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/408387/408387/ReadMessage.aspx#408387"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Hello all,&lt;br /&gt;
&lt;br /&gt;
i came across a interesting question about displaying Roman character&lt;br /&gt;
when the input is number.&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------&lt;br /&gt;
For example :&lt;br /&gt;
&lt;br /&gt;
1	i	50	l	364	ccclxiiii&lt;br /&gt;
2	ii	100	c	2222	mmccxxii&lt;br /&gt;
5	v	500	d&lt;br /&gt;
7	vii	1000	m&lt;br /&gt;
10      x&lt;br /&gt;
---------------------------------------------------&lt;br /&gt;
And to make the programming more challenging, only "getchar()" command&lt;br /&gt;
is allowed to get input from the users.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I somehow managed to create the code to get the input from users.&lt;br /&gt;
For example : input : 3456 , i am able to capture "3456" n convert into integer for further processing.&lt;br /&gt;
-----------------------------------------------&lt;br /&gt;
printf("input ?: ");  &lt;br /&gt;
 number = 0;&lt;br /&gt;
 ch = getchar();&lt;br /&gt;
&lt;br /&gt;
 while(ch != '\n')&lt;br /&gt;
    {&lt;br /&gt;
     if('0' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= '9')&lt;br /&gt;
      {&lt;br /&gt;
       number = number * 10;&lt;br /&gt;
       number = number + (ch - '0');&lt;br /&gt;
      }&lt;br /&gt;
    ch=getchar();&lt;br /&gt;
   }&lt;br /&gt;
-----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Just wondering anyone has any idea on how to convert n display&lt;br /&gt;
Roman characters equivalent to that particular input</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/408387/408387/ReadMessage.aspx#408387</guid>
      <pubDate>Tue, 27 Oct 2009 01:28:19 -0700</pubDate>
    </item>
    <item>
      <title>Advanced output formatting help needed</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/408368/408368/ReadMessage.aspx#408368</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/Npman5/"&gt;Npman5&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/408368/408368/ReadMessage.aspx#408368"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;I am doing a project for my object oriented class and it generates a random number into an array and then counts the number of instances for each number generated and spits that out. The problem I am having is getting the formatting to look right on my output. I would like my output to have the number that is being examined in the array, then a single space, and then a specific number of '-' characters and then a single space and then the number of instances of the examined number.&lt;br /&gt;
&lt;br /&gt;
the line of my output is as follows&lt;br /&gt;
&lt;pre class="sourcecode"&gt;cout &amp;lt;&amp;lt; value &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; right &amp;lt;&amp;lt; setfill('-') &amp;lt;&amp;lt; setw(5) &amp;lt;&amp;lt; ' ' &amp;lt;&amp;lt; valueCount &amp;lt;&amp;lt; endl;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
value is the current number that is being looked at&lt;br /&gt;
valueCount is the number of that value that are found in the array&lt;br /&gt;
I have iostream, cstdlib, and iomanip included with #include&lt;br /&gt;
&lt;br /&gt;
I keep getting output that looks like this:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;8 ---- 500
9 ---- 489
10 ---- 531
11 ---- 521&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I want it to look like this:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;8 ----- 500
9 ----- 489
10 ---- 531
11 ---- 521&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I want the numbers on the right to match up after an arbitrary amount of space and have the number of '-' characters change depending on how many characters there are from the start of the counted number. preferably this would all be in a single cout stream.&lt;br /&gt;
Thanks for all the help in advance.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/408368/408368/ReadMessage.aspx#408368</guid>
      <pubDate>Mon, 26 Oct 2009 17:04:09 -0700</pubDate>
    </item>
    <item>
      <title>Re: how to solve this problem??</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/402213/408201/ReadMessage.aspx#408201</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/402213/408201/ReadMessage.aspx#408201"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;If you want you can leave out the line&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;continue;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
since there is no code between the end of the if block and the closing of the for block.  &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/402213/408201/ReadMessage.aspx#408201</guid>
      <pubDate>Fri, 23 Oct 2009 08:33:44 -0700</pubDate>
    </item>
    <item>
      <title>Re: Converting Hex to Decimal</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/407988/408122/ReadMessage.aspx#408122</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/407988/408122/ReadMessage.aspx#408122"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Basically, since you cannot use toupper() or bit manipulation in your program then you need to divide your if statement into three tests.&lt;br /&gt;
&lt;br /&gt;
First test for characters in the range of '0' to '9' like your doing and then instead of trying to do everything in the first if clause use an 'else if' to test the remaining to clauses.&lt;br /&gt;
&lt;br /&gt;
if('0' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= '9')&lt;br /&gt;
&lt;pre class="sourcecode"&gt;{
  ...
}
else if('A' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= 'F')   /* test only valid hexadecimal characters */
{
  ...
}
else if('a' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= 'f')
{
  ...
}
&lt;/pre&gt;&lt;br /&gt;
 &lt;br /&gt;
You will need to use slightly different logic to get the right values for the letters A-F and a-f.  It will be similar to your logic above in that you will subtract the starting offset from ch; however, you have to remember to adjust the value so that you get 10 for A.&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/407988/408122/ReadMessage.aspx#408122</guid>
      <pubDate>Thu, 22 Oct 2009 08:49:17 -0700</pubDate>
    </item>
    <item>
      <title>Re: Difference between Visual C++ and C++.NET ?</title>
      <link>http://www.programmersheaven.com/mb/cppnet/408040/408049/ReadMessage.aspx#408049</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/cppnet/408040/408049/ReadMessage.aspx#408049"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/cppnet/Board.aspx"&gt;C++.NET&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;C++.NET is managed code (like C#), however - it can mix with the "normal" C++. I find it very frustrating.&lt;br /&gt;
&lt;br /&gt;
There is a comparison of these languages &lt;a href="http://en.wikipedia.org/wiki/Managed_Extensions_for_C%2B%2B"&gt;here&lt;/a&gt;.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/cppnet/408040/408049/ReadMessage.aspx#408049</guid>
      <pubDate>Wed, 21 Oct 2009 15:56:05 -0700</pubDate>
    </item>
    <item>
      <title>Re: Converting Hex to Decimal</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/407988/408021/ReadMessage.aspx#408021</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/407988/408021/ReadMessage.aspx#408021"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;It is a step in the right direction. However, if ch is 'A' how will it give the proper value if you do (ch-'0')? Try to test your code with string "A" - the decimal result must be 10, but I doubt it will be. Also, lower case "a" input will not work.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/407988/408021/ReadMessage.aspx#408021</guid>
      <pubDate>Wed, 21 Oct 2009 04:34:24 -0700</pubDate>
    </item>
    <item>
      <title>Re: Converting Hex to Decimal</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/407988/408012/ReadMessage.aspx#408012</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/spurs01/"&gt;spurs01&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/407988/408012/ReadMessage.aspx#408012"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Hello ,&lt;br /&gt;
&lt;br /&gt;
thank you very much for the advice.&lt;br /&gt;
Because the teacher only taught us basic instructions ( Getchar(),Putchar(),While Loop, if etc ), i don't think he will accept complex functions like "Changing to UPPER Case", "Shift (logical) RESULT to the left by 4 bits" etc...&lt;br /&gt;
&lt;br /&gt;
The algorithm looks similer to my coding ( At least my approach looks correct )&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
  int number;&lt;br /&gt;
  int ch;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
  printf("input ? ");&lt;br /&gt;
  &lt;br /&gt;
  number = 0;&lt;br /&gt;
  ch = getchar();&lt;br /&gt;
  &lt;br /&gt;
 while(ch != '\n')&lt;br /&gt;
    {&lt;br /&gt;
        if(('0' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;lt;= '9')||('A' &amp;lt;= ch &amp;amp;&amp;amp; ch &amp;amp;&amp;amp; ch &amp;lt;= 'Z'))&lt;br /&gt;
         {&lt;br /&gt;
           number = number * 16;&lt;br /&gt;
           number = number + (ch - '0');&lt;br /&gt;
         }&lt;br /&gt;
        &lt;br /&gt;
&lt;br /&gt;
     ch = getchar();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
  printf("your input number is %d\n",number);&lt;br /&gt;
}</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/407988/408012/ReadMessage.aspx#408012</guid>
      <pubDate>Tue, 20 Oct 2009 20:36:08 -0700</pubDate>
    </item>
    <item>
      <title>Re: Converting Hex to Decimal</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/407988/407990/ReadMessage.aspx#407990</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/407988/407990/ReadMessage.aspx#407990"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;Here is the algorithm of doing it the hard way:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
1.  RESULT=0
1a. Declare integer variable BINDIGIT
1b. PRINT "Enter hexadecimal text: "

2.  CHARACTER = getchar ()
2a. IF (CHARACTER is ENTER) THEN GO TO step 7.
2b. Turn CHARACTER into upper case

3. IF (CHARACTER is in range ['0'..'9']) THEN BINDIGIT = CHARACTER - '0'
   ELSE IF (CHARACTER is in range ['A'..'F']) THEN BINDIGIT = (CHARACTER - 'A') + 10
   ELSE
    BEGIN
     PRINT "Invalid character entered"
     EXIT PROGRAM or loop it to get another input text (step 1b)
    END

4. Shift (logical) RESULT to the left by 4 bits
5. Perform: RESULT = RESULT bitwise OR with BINDIGIT
6. GO TO step 2.

7. PRINT RESULT
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/407988/407990/ReadMessage.aspx#407990</guid>
      <pubDate>Tue, 20 Oct 2009 04:38:50 -0700</pubDate>
    </item>
    <item>
      <title>Converting Hex to Decimal</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/407988/407988/ReadMessage.aspx#407988</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/spurs01/"&gt;spurs01&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/407988/407988/ReadMessage.aspx#407988"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Hello ,&lt;br /&gt;
&lt;br /&gt;
anyone knows how to convert Hex(input) to decimal ?&lt;br /&gt;
&lt;br /&gt;
For example :  3E8 -&amp;gt; the output will display 1000.&lt;br /&gt;
&lt;br /&gt;
To take in input from user , we can only use getchar()&lt;br /&gt;
&lt;br /&gt;
cheer&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/407988/407988/ReadMessage.aspx#407988</guid>
      <pubDate>Tue, 20 Oct 2009 02:52:35 -0700</pubDate>
    </item>
    <item>
      <title>Re: Need help in data arrangement....</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/407925/407927/ReadMessage.aspx#407927</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/anthrax11/"&gt;anthrax11&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/407925/407927/ReadMessage.aspx#407927"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;There are two 87s in the list, so I don't know how you can have no repeating values.&lt;br /&gt;
&lt;br /&gt;
Anyway, I don't think this can be done. The 5th and 6th largest values are 87 and 85 respectively. Assuming we put the 5 largest values into 5 separate boxes, then we should be able to put the 6th largest value somewhere, but 85 + 87 &amp;gt; 130.&lt;br /&gt;
&lt;br /&gt;
Also, the sum of all boxes should be a maximum of 130*5=650, but all the values add up to 1113. Maybe you meant to say the maximum should be 230?</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/407925/407927/ReadMessage.aspx#407927</guid>
      <pubDate>Sat, 17 Oct 2009 04:46:38 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/407895/ReadMessage.aspx#407895</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/407895/ReadMessage.aspx#407895"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;As an aid to helping you troubleshoot your own applications in the future, I will show you how I was able to discover what was wrong with your program.&lt;br /&gt;
&lt;br /&gt;
Basically, I took and commented out each function definition in your program by doing this&lt;br /&gt;
&lt;br /&gt;
void Block::doSomething(int x, string y)&lt;br /&gt;
{&lt;br /&gt;
/*&lt;br /&gt;
 ...&lt;br /&gt;
*/ &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
or if the function had to return a value&lt;br /&gt;
&lt;br /&gt;
int Block::getValue()&lt;br /&gt;
{&lt;br /&gt;
   int x;&lt;br /&gt;
/*&lt;br /&gt;
  ...&lt;br /&gt;
*/ return x;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Then I compiled the program to see if there were any compile errors.  The first time the program was compiled it indicated that your main() was invalid and then it listed a few more errors after that, but it wasn't a couple pages like the first time.   After correcting the main() errors, I un-commented the previous function definitions one at a time to see what errors were being thrown.  I noticed that the errors dealt with the find() not being declared, so that led me to think that you had failed to include the appropriate library.&lt;br /&gt;
&lt;br /&gt;
Now, I could have figured out many of the errors without commenting out the function definitions by looking at the listing, but it makes it easier to breakdown the program into smaller parts and eliminate the errors in each of those parts than to try a wade through a couple of pages of error messages and decipher their meanings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some helpful hints:&lt;br /&gt;
&lt;br /&gt;
   If you are using a standard (or third-party) library function and the compiler tells you it is undefined or it cannot find a match for it then you are probably missing an include statement.  &lt;br /&gt;
&lt;br /&gt;
   If you get an error indicating a missing closing ) or } or ; then correct the first error you see missing a closing ),}, or ; since it is probably causing the compiler to go berserk and spew out a whole bunch of other errors.&lt;br /&gt;
&lt;br /&gt;
   Another useful practice is to compile your program after each function/class definition to see if you get any unexpected syntax errors.  If you do this periodically while writing the program then it makes it a lot easier to debug when the program is finished since you can pretty much guess where the errors are located.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/407895/ReadMessage.aspx#407895</guid>
      <pubDate>Fri, 16 Oct 2009 12:48:24 -0700</pubDate>
    </item>
    <item>
      <title>How Database Design Helps or Hinders Interoperability and Maintainability of an Application</title>
      <link>http://www.programmersheaven.com/user/alaniane/blog/1628-How-Database-Design-Helps-or-Hinders-Interoperability-and-Maintainability-of-an-Application/</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; wrote a &lt;a href="http://www.programmersheaven.com/user/alaniane/blog/1628-How-Database-Design-Helps-or-Hinders-Interoperability-and-Maintainability-of-an-Application/"&gt;new blog post&lt;/a&gt; in their &lt;a href="http://www.programmersheaven.com/user/alaniane/blog/"&gt;blog&lt;/a&gt;.&lt;/p&gt;   An often overlooked aspect of application development is how to design the database so that it facilitates maintaining the application.  This can be especially crucial when an application offers users the ability to customize it or it is to be used in conjunction with third-party applications.  &lt;br /&gt;
   Applications today frequently have to interop with third-party applications.  One of the reasons for the success of the Windows platform was OLE and DDE which allowed different applications to share common data between them.  So, how can we design the back end database, so that third-party applications can interop with our application?  How can the way we design the data tables affect the maintainability of our application?&lt;br /&gt;
   In this paper I will cover two design problems and show how the affect the way other applications can interop with our application and how they can either hinder or facilitate the customizing our application.  The first deals with designing a back end database so as to leverage the power of relational databases.  When you are designing an object-oriented application, a common novice's mistake is to think that you have to have a separate class design for each type of object.  This probably comes from beginner's programming textbooks that use examples like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;class Shape{
...
};

class Rectangle: public Shape{
...
};

class Square: public Rectangle{
...
};
&lt;/pre&gt;&lt;br /&gt;
to illustrate inheritance and polymorphism.  Unfortunately, programmers can tend to apply the same principles to the way they design files or databases to be used by their programs.  One program I had to interface with created separated databases for handling domestic and international shipments.  Basically, the only difference between the two databases was that one handled shipments that occurred within a country and another handled shipments between countries.  The exact same tables were used by both databases and the exact same columns occurred in the tables for the two databases.  &lt;br /&gt;
    Now, why is this a bad idea when it comes to maintaining an application?  A large part of maintaining software is to extend an application to incorporate new or changing business rules within an organization.  For example in the above scenario, if an organization decides to change the way it calculates shipping rates and this organization uses the same formula for both domestic and international shipments then the programmer has to remember to change the calculation in two different areas.   Or if the organization decides to split domestic shipments into local shipments which only involve shipments within the same metropolitan area and inter-province or interstate shipments then a third and possibly fourth database has to be created multiplying the possibility of errors occurring when existing business rules have to be changed.&lt;br /&gt;
    A much better design for this database would have been to have just included one extra column to the shipments table indicating whether the shipment was domestic or international.  Then shipment rates could be updated for one table in the database and applied across the different types of shipments.  Also, to add a different type of domestic shipment would have only required changing the data in one column in one table of the database.  This would have meant that instead of having to re-compile the application for the new type of domestic shipments, it may have been possible to only have to update the database.   Let's go back to the class example presented above.  A better implementation for the example would have been to recognize that a square is a type of rectangle and unless our application required special rules for implementing squares it should have been just declared an object and not a separate class like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;class Shape{
...
};

class Rectangle : public Shape{
...
};


Rectangle square;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
A simple comparison of the width and length of the Rectangle object would have indicated whether it was a square or not.  So, if there is a table listing furniture:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;tblFurniture{Id, Type, NumberOfLegs, ...}
&lt;/pre&gt;&lt;br /&gt;
If one needed to distinguish between wood and metal furniture, then instead of creating two tables:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;tblMetalFurniture{Id, Type, NumberOfLegs,...}
tblWoodFurniture{Id, Type, NumberOfLegs,...}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
it would be better to just add one additional column to tblFurniture indicating the type of material used to construct the furniture:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;tblFurniture{Id, Type, NumberOfLegs,...,MaterialMadeFrom}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Later on if the business started selling plastic furniture then one would only need to add this material type to the MaterialMadeFrom column rather than creating a whole new data table.  So, the proc updating the table would not need to have a complicated if...else or case block but could just be used as is since the material type could be passed in as a parameter.   So, instead of having a stored proc:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;CREATE PROC AddFurniture
(
  @Type VARCHAR(50),
  @NumOfLegs   INT,
  ...,
  @MaterialId INT 
)
AS
IF @MaterialId == 1
...
ELSE IF @MaterialId == 2
...
ELSE
....
END&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
One could write&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;CREATE PROC AddFurniture
(
  @Type VARCHAR(50),
  @NumOfLegs   INT,
  ...,
  @MaterialId INT 
)
AS
...
INSERT INTO tblFurniture( Type, NumberOfLegs,...,MaterialMadeFrom)
VALUES(@Type, @NumOfLegs,...,@MaterialId)
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The second proc is easier to follow and a lot easier to maintain than the first proc.  In the second part I will talk about how choosing a column layout in a data table can affect the maintainability of an application.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/user/alaniane/blog/1628-How-Database-Design-Helps-or-Hinders-Interoperability-and-Maintainability-of-an-Application/</guid>
      <pubDate>Fri, 16 Oct 2009 12:26:01 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/407509/ReadMessage.aspx#407509</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/chuckw1/"&gt;chuckw1&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/407509/ReadMessage.aspx#407509"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Thanks for all your help seems to be working now.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/407509/ReadMessage.aspx#407509</guid>
      <pubDate>Thu, 15 Oct 2009 10:59:02 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/407190/ReadMessage.aspx#407190</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/407190/ReadMessage.aspx#407190"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Finally, you are missing an include file #include &amp;lt;algorithms&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You need this file for the find().&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/407190/ReadMessage.aspx#407190</guid>
      <pubDate>Wed, 14 Oct 2009 20:43:52 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/407189/ReadMessage.aspx#407189</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/407189/ReadMessage.aspx#407189"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;I had a chance to compile your program using gcc compiler.  Your main() declaration is invalid.  I'm not sure if the Visual C++ compiler will allow the declaration, but there are only two valid standard C++ main() declarations:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;int main()
{
  ...
}

int main(int argc, char *argv[])
{
  ...
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The other problem is the statement&lt;br /&gt;
&lt;br /&gt;
Block block();&lt;br /&gt;
&lt;br /&gt;
at least the gcc compiler would not parse that expression.&lt;br /&gt;
&lt;br /&gt;
You should write&lt;br /&gt;
&lt;br /&gt;
Block block;&lt;br /&gt;
&lt;br /&gt;
Also, in order for you to use block in the cout statement like&lt;br /&gt;
&lt;br /&gt;
cout&amp;lt;&amp;lt; block;&lt;br /&gt;
&lt;br /&gt;
You have to overload the operator&amp;lt;&amp;lt;  for the Block class.  Otherwise you have to write the statement like&lt;br /&gt;
&lt;br /&gt;
cout&amp;lt;&amp;lt; block.toString(); &lt;br /&gt;
&lt;br /&gt;
since string is already has the operator&amp;lt;&amp;lt; overloaded for it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/407189/ReadMessage.aspx#407189</guid>
      <pubDate>Wed, 14 Oct 2009 20:27:15 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/406967/ReadMessage.aspx#406967</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/chuckw1/"&gt;chuckw1&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/406967/ReadMessage.aspx#406967"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;: Are you having problems compiling the code or are these runtime &lt;br /&gt;
: errors?&lt;br /&gt;
: &lt;br /&gt;
: If they are runtime errors then I would suggest setting a breakpoint &lt;br /&gt;
: on the line &lt;br /&gt;
: &lt;br /&gt;
: Block block();&lt;br /&gt;
: &lt;br /&gt;
: and running the code in a debugger.  You could step through the code &lt;br /&gt;
: to see where the exception is being thrown.  &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
These are compiler errors.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/406967/ReadMessage.aspx#406967</guid>
      <pubDate>Wed, 14 Oct 2009 15:22:22 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/406963/ReadMessage.aspx#406963</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/406963/ReadMessage.aspx#406963"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Are you having problems compiling the code or are these runtime errors?&lt;br /&gt;
&lt;br /&gt;
If they are runtime errors then I would suggest setting a breakpoint on the line &lt;br /&gt;
&lt;br /&gt;
Block block();&lt;br /&gt;
&lt;br /&gt;
and running the code in a debugger.  You could step through the code to see where the exception is being thrown.  &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/406963/ReadMessage.aspx#406963</guid>
      <pubDate>Wed, 14 Oct 2009 14:43:06 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/406642/ReadMessage.aspx#406642</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/chuckw1/"&gt;chuckw1&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/406642/ReadMessage.aspx#406642"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;: You declared a default constructor for Block&lt;br /&gt;
: &lt;br /&gt;
: class Block&lt;br /&gt;
: { &lt;br /&gt;
:   ...&lt;br /&gt;
:   public:&lt;br /&gt;
:     Block();&lt;br /&gt;
:   ...&lt;br /&gt;
: }&lt;br /&gt;
: &lt;br /&gt;
: But you didn't define the constructor.  If you only wanted a blank &lt;br /&gt;
: constructor, you could either not declared one and let the compiler &lt;br /&gt;
: create one for you or you need to change&lt;br /&gt;
: &lt;br /&gt;
:     Block();&lt;br /&gt;
: &lt;br /&gt;
: to &lt;br /&gt;
:     Block(){}&lt;br /&gt;
: &lt;br /&gt;
: The program can't construct the Block object, so that's why none of &lt;br /&gt;
: your function calls work.&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have tried taking out Block(); so that it will create a default one and I have also tried changing to Block(){}; but that doesn't seem to fix it. Any other suggestions? Thanks</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/406642/ReadMessage.aspx#406642</guid>
      <pubDate>Wed, 14 Oct 2009 08:02:52 -0700</pubDate>
    </item>
    <item>
      <title>C++/C# Programmer for hire</title>
      <link>http://www.programmersheaven.com/mb/jobs-wanted/406633/406633/ReadMessage.aspx#406633</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/Jaytee/"&gt;Jaytee&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/jobs-wanted/406633/406633/ReadMessage.aspx#406633"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/jobs-wanted/Board.aspx"&gt;Jobs Wanted&lt;/a&gt; forum.&lt;/p&gt;Hello!&lt;br /&gt;
&lt;br /&gt;
I'm experienced C++ programmer targetting also into C# programming.&lt;br /&gt;
I'm looking for job, preferably telecommute.&lt;br /&gt;
&lt;br /&gt;
If you need C++ or C# programmer for developing Windows application please contact with me.&lt;br /&gt;
&lt;br /&gt;
Thank you!&lt;br /&gt;
Jaytee&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/jobs-wanted/406633/406633/ReadMessage.aspx#406633</guid>
      <pubDate>Wed, 14 Oct 2009 07:29:49 -0700</pubDate>
    </item>
    <item>
      <title>Re: Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/406422/ReadMessage.aspx#406422</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/406422/ReadMessage.aspx#406422"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;You declared a default constructor for Block&lt;br /&gt;
&lt;br /&gt;
class Block&lt;br /&gt;
{ &lt;br /&gt;
  ...&lt;br /&gt;
  public:&lt;br /&gt;
    Block();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
But you didn't define the constructor.  If you only wanted a blank constructor, you could either not declared one and let the compiler create one for you or you need to change&lt;br /&gt;
&lt;br /&gt;
    Block();&lt;br /&gt;
&lt;br /&gt;
to &lt;br /&gt;
    Block(){}&lt;br /&gt;
&lt;br /&gt;
The program can't construct the Block object, so that's why none of your function calls work.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/406422/ReadMessage.aspx#406422</guid>
      <pubDate>Tue, 13 Oct 2009 23:37:12 -0700</pubDate>
    </item>
    <item>
      <title>Help with code please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/406354/406354/ReadMessage.aspx#406354</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/chuckw1/"&gt;chuckw1&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/406354/406354/ReadMessage.aspx#406354"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;I am having troubles compiling my code. For some reason it doesn't like my call to block.init() or any of my other calls. Can someone please help?&lt;br /&gt;
&lt;pre class="sourcecode"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;

using namespace std;


//**************************************************************START ON
class ON
	{
		

	public:
		ON(string a, string b);

		bool Equals(ON on2);

		string ToString();
		
		string a, b;
	};
	
	ON::ON(string a, string b)
	{
		this-&amp;gt;a = a;
		this-&amp;gt;b = b;
	
	}
	
	bool ON::Equals(ON on2)
	{
		return a == on2.a &amp;amp;&amp;amp;  b == on2.b;
	}

	string ON::ToString()
	{
		return "on("+a+", "+b+")";
	}

// *******************************************************************END ON


class Block
	{

	private:
		vector&amp;lt;string&amp;gt; ontables;
		vector&amp;lt;string&amp;gt; clears;
		vector&amp;lt;ON&amp;gt; ons;
		string holding;
		bool handempty;

	public:
           Block();

		void pickup(string a);

		void putdown(string a);

		void stack(string a, string b);

		void unstack(string a, string b);

		vector&amp;lt;string&amp;gt; getOntables();

		bool isOntable(string a);

		vector&amp;lt;string&amp;gt; getClears();

		bool isClear(string a);

		vector&amp;lt;ON&amp;gt; getOns();
		
        bool isOn(string a, string b);

	private:
		void removeOn(string a, string b);

	public:
		string getHolding();

		bool isHolding(string thing);

		bool isHandempty();

		void setHandempty(bool empty);

		string ToString();

		void init();

	};

	void Block::pickup(string a)
	{
        vector&amp;lt;string&amp;gt;::iterator p;
        vector&amp;lt;string&amp;gt;::iterator p2;
        bool d, d2;
        p = find(ontables.begin(), ontables.end(), a);
        p2 = find(clears.begin(), clears.end(), a);
        if( p == ontables.end() ) {
            d = false;
        }
        else {
             d = true;
        }
        if( p2 == clears.end() ) {
            d2 = false;
        }
        else {
             d2 = true;
        }

        
		if (d &amp;amp;&amp;amp; d2 &amp;amp;&amp;amp; handempty)
		{
			p = ontables.erase( p );
            p2 = clears.erase( p2 );

			handempty = false;
			holding = a;
		}
		else
			cout &amp;lt;&amp;lt; "Cannot pickup " &amp;lt;&amp;lt; a;
	}

	void Block::putdown(string a)
	{
		if (holding!="")
		{
			holding = "";
			ontables.push_back(a);
			clears.push_back(a);
			handempty = true;
		}
		else
			cout &amp;lt;&amp;lt; "Cannot put down " &amp;lt;&amp;lt; a;
	}

	void Block::stack(string a, string b)
	{
        vector&amp;lt;string&amp;gt;::iterator p;
        bool d;
        p = find(clears.begin(), clears.end(), b);
        if( p == clears.end() ) {
            d = false;
        }
        else {
             d = true;
        }
 
		if (a!=b &amp;amp;&amp;amp; holding!="" &amp;amp;&amp;amp; holding == a &amp;amp;&amp;amp; d)
		{
			handempty=true;
			ons.push_back(ON(a , b));
			p = clears.erase( p );
			clears.push_back(a);
			holding = "";
		}
		else
			cout &amp;lt;&amp;lt; "Cannot stack " &amp;lt;&amp;lt; a &amp;lt;&amp;lt; " on " &amp;lt;&amp;lt; b;
	}

	void Block::unstack(string a, string b)
	{
        vector&amp;lt;string&amp;gt;::iterator p;
        bool d;
        p = find(clears.begin(), clears.end(), a);
        if( p == clears.end() ) {
            d = false;
        }
        else {
             d = true;
        }
        
		if (handempty &amp;amp;&amp;amp; d &amp;amp;&amp;amp; (isOn(a, b)))
		{
			handempty = false;
			p = clears.erase( p );
			removeOn(a, b);
			holding = a;
			clears.push_back(b);
		}
		else
			cout &amp;lt;&amp;lt; "Cannot unstack " &amp;lt;&amp;lt; a &amp;lt;&amp;lt; " from " &amp;lt;&amp;lt; b;
	}

	vector&amp;lt;string&amp;gt; Block::getOntables()
	{
		return ontables;
	}

	bool Block::isOntable(string a)
	{
        vector&amp;lt;string&amp;gt;::iterator p;
        bool d;
        p = find(ontables.begin(), ontables.end(), a);
        if( p == ontables.end() ) {
            d = false;
        }
        else {
             d = true;
        }
        
		return d;
	} 

	vector&amp;lt;string&amp;gt; Block::getClears()
	{
		return clears;
	}

	bool Block::isClear(string a)
	{
        vector&amp;lt;string&amp;gt;::iterator p;
        bool d;
        p = find(clears.begin(), clears.end(), a);
        if( p == clears.end() ) {
            d = false;
        }
        else {
             d = true;
        }
        
		return d;
	} 

	vector&amp;lt;ON&amp;gt; Block::getOns()
	{
		return ons;
	}

	bool Block::isOn(string a, string b)
	{
		ON on2(a, b);
		//for (vector&amp;lt;ON&amp;gt;::const_iterator on = ons.begin(); on != ons.end(); on++)
		for (int on = 0; on &amp;lt; ons.size(); on++)
        	if (ons[on].Equals(on2))
				return true;
		return false;
	}

	void Block::removeOn(string a, string b)
	{
         ON on2(a, b);
		for (int i=ons.size() - 1; i&amp;gt;=0; i--)
		{            
			if (ons[i].Equals(on2))
			{
               //ons.erase( i );
			   //ons.remove(i);
				return;
			}
		}
	}

	string Block::getHolding()
	{
		return holding;
	}

	bool Block::isHolding(string thing)
	{
		return holding != "" &amp;amp;&amp;amp; holding == thing;
	}

	bool Block::isHandempty()
	{
		return handempty;
	}

	void Block::setHandempty(bool empty)
	{
		handempty = empty;
	}

	string Block::ToString()
	{
		string str = "";
		int i;
		//for (vector&amp;lt;string&amp;gt;::const_iterator ontable = ontables.begin(); ontable != ontables.end(); ontable++)
		for(i = 0; i &amp;lt; ontables.size(); i++)
        	str += "\n\tontable("+ontables[i]+")";
		//for (vector&amp;lt;string&amp;gt;::const_iterator clear = clears.begin(); clear != clears.end(); clear++)
		for(i = 0; i &amp;lt; clears.size(); i++)
        	str += "\n\tclear("+clears[i]+")";
		//for (vector&amp;lt;ON&amp;gt;::const_iterator on = ons.begin(); on != ons.end(); on++)
		for(i = 0; i &amp;lt; ons.size(); i++)
        	str += "\n\t" +ons[i].a+ons[i].b;
		if (holding!="")
			str += "\n\tholding("+ holding+")";
		if (handempty)
			str += "\n\thandempty(\"r\")";
		return str;
	}

	void Block::init()
	{
        ON temp("1","3");
		ontables.push_back("3");
		ontables.push_back("6");
		clears.push_back("1");
		clears.push_back("6");
		ons.push_back(temp);
		handempty = true;
	}
//************************************************************END BLOCK

	int main(string args[])
	{
		/*ON on2("a", "b");
		string s = on2.ToString();
		cout &amp;lt;&amp;lt; s;*/
		Block block();
        block.init();
	    block.unstack("1", "3");
		block.putdown("1");
		block.pickup("6");
	    block.stack("6", "1");
	    cout &amp;lt;&amp;lt; "Final state: " &amp;lt;&amp;lt; block;
		    system("PAUSE");
		return 0;
	
	}

&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/406354/406354/ReadMessage.aspx#406354</guid>
      <pubDate>Tue, 13 Oct 2009 18:44:14 -0700</pubDate>
    </item>
    <item>
      <title>Re: Implementation</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/398826/405992/ReadMessage.aspx#405992</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/alaniane/"&gt;alaniane&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/398826/405992/ReadMessage.aspx#405992"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Part of your problem is the way you designed your struct.  When you look at the requirements, it mentions last name as distinct from first name, so instead of creating just char name[] variable create two separate variables for first and last names.  That will make sorting easier.  Also, think about ways of separating the student structure from the list node structure.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/398826/405992/ReadMessage.aspx#405992</guid>
      <pubDate>Tue, 13 Oct 2009 07:24:46 -0700</pubDate>
    </item>
    <item>
      <title>Re: Forums no longer moderated</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/397624/405830/ReadMessage.aspx#405830</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/pseudocoder/"&gt;pseudocoder&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/397624/405830/ReadMessage.aspx#405830"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/CandCPP/Board.aspx"&gt;C and C++&lt;/a&gt; forum.&lt;/p&gt;I haven't posted here in years, and couldn't believe how much spam has taken over this place... the older board was better, I think.&lt;br /&gt;
&lt;br /&gt;
Nonetheless, it's nice the see that the "captcha" stuff is preventing spammers from posting... I've always loved that feature, and I'm elated that I must use it each time I post or preview. :P&lt;br /&gt;
&lt;br /&gt;
I guess it's a mute point now, but here's a belated congrats on the mod position Lundin, or perhaps the un-mod position. :)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/397624/405830/ReadMessage.aspx#405830</guid>
      <pubDate>Tue, 13 Oct 2009 03:33:14 -0700</pubDate>
    </item>
    <item>
      <title>Re: help me with isalpha</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/402004/405828/ReadMessage.aspx#405828</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/pseudocoder/"&gt;pseudocoder&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/402004/405828/ReadMessage.aspx#405828"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;&lt;pre class="sourcecode"&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;ctype.h&amp;gt;

int main(void)	{

   int numbers[] = { 121, 97, 4545, 300, 34, 76 }, i;

   for(i=0; i &amp;lt; sizeof(numbers)/sizeof(int); i++) {
      printf("%4d %10s [%c]\n", numbers[i], 
             isalpha(numbers[i]) ? "isalpha" : "not alpha",
             isalpha(numbers[i]) ? numbers[i] : ' ');
   }

   return (0);
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Not sure what you're asking...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/402004/405828/ReadMessage.aspx#405828</guid>
      <pubDate>Tue, 13 Oct 2009 03:09:14 -0700</pubDate>
    </item>
    <item>
      <title>Re: Input validation</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/402097/405822/ReadMessage.aspx#405822</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/pseudocoder/"&gt;pseudocoder&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/402097/405822/ReadMessage.aspx#405822"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;The best I can recall, all of C's standard input functions are buffered, so they may return junk until the buffer is cleared.  I'm also not sure if a char can be used for EOF... I *think* it has be of type int, but I'm still quite rusty with C / C++.  &lt;br /&gt;
&lt;br /&gt;
When I played around with C a few years ago, I used something like below to validate input.  &lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;ctype.h&amp;gt;

int main(void)	{

   char s[2] = { 0 }, *p;

   do {

      printf("A(AM) or P(PM): ");
      fgets(s, sizeof s, stdin);

      if((p = strchr(s, '\n')) == NULL) {
         while(getchar() != '\n'){} // eat the buffer
      }

   } while(toupper(s[0]) != 'A' &amp;amp;&amp;amp; toupper(s[0]) != 'P');   
	 
   return (0);
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
HTH</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/402097/405822/ReadMessage.aspx#405822</guid>
      <pubDate>Tue, 13 Oct 2009 02:50:40 -0700</pubDate>
    </item>
    <item>
      <title>Re: how to solve this problem??</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/402213/405818/ReadMessage.aspx#405818</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/pseudocoder/"&gt;pseudocoder&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/402213/405818/ReadMessage.aspx#405818"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;Just for grins, how about something like&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

int main(void)	{

   int num[5] = { 0 }, i = 0;
   char nbuf[32] = { 0 };

   while(i &amp;lt; 5) {

      do {

         printf("%s number %d\n", num[i] &amp;gt; 11 ? "please reenter" : "enter", i + 1);	 
         fgets(nbuf, sizeof nbuf, stdin);

      } while((sscanf(nbuf, "%d", &amp;amp;num[i]) != 1) || num[i] &amp;gt; 11);

      i++;
   }

   printf("\n\nThe numbers are: ");

   for(i=0; i&amp;lt;5; i++)
      printf("%d ", num[i]);
	 
   return (0);
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
HTH&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/402213/405818/ReadMessage.aspx#405818</guid>
      <pubDate>Tue, 13 Oct 2009 02:31:31 -0700</pubDate>
    </item>
    <item>
      <title>Re: prompting until given a postive odd integer</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/405355/405815/ReadMessage.aspx#405815</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/pseudocoder/"&gt;pseudocoder&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/405355/405815/ReadMessage.aspx#405815"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;You *might* try the do-while loop instead.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;cassert&amp;gt;

using namespace std;

int main(void) {

   int x;

   do {

      cout &amp;lt;&amp;lt; "enter an odd positive integer: ";
      cin &amp;gt;&amp;gt; x;

      assert(cin.good()); // loopy alert

   } while(x % 2 == 0 || x &amp;lt; 0);

   cout &amp;lt;&amp;lt; "you entered: " &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;

   return (0);
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
As mentioned, you may also want to use a char[] or string to read in the number and then use a conversion function in case someone enters invalid input.  &lt;br /&gt;
&lt;br /&gt;
HTH</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/405355/405815/ReadMessage.aspx#405815</guid>
      <pubDate>Tue, 13 Oct 2009 01:53:21 -0700</pubDate>
    </item>
    <item>
      <title>Re: prompting until given a postive odd integer</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/405355/405811/ReadMessage.aspx#405811</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/AsmGuru62/"&gt;AsmGuru62&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/405355/405811/ReadMessage.aspx#405811"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/beginnercpp/Board.aspx"&gt;Beginner C/C++&lt;/a&gt; forum.&lt;/p&gt;&lt;pre class="sourcecode"&gt;: int x&lt;span style="color: Red;"&gt;=0&lt;/span&gt;;
: cout &amp;lt;&amp;lt; endl;
: while ( (x%2 == 0)||(x&amp;lt;=0) ) {
: cout &amp;lt;&amp;lt; "Enter an odd positive integer: ";  // if x is &amp;gt;0 prompt
: cin &amp;gt;&amp;gt; x;
: }
: cout &amp;lt;&amp;lt; endl;
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/405355/405811/ReadMessage.aspx#405811</guid>
      <pubDate>Tue, 13 Oct 2009 01:22:46 -0700</pubDate>
    </item>
  </channel>
</rss>