<?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 2012 Programmers Heaven</copyright>
    <pubDate>Thu, 09 Feb 2012 06:32:39 -0800</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>91 bugs in C++ projects</title>
      <link>http://www.programmersheaven.com/link/16179-91+bugs+in+C+++projects/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/Karpov2007/"&gt;Karpov2007&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/link/16179-91+bugs+in+C%2b%2b+projects/info.aspx"&gt;link&lt;/a&gt;.&lt;/p&gt;A lot of examples of errors are cited found by the analyzer in various Open-Source projects.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/link/16179-91+bugs+in+C%2b%2b+projects/info.aspx</guid>
      <pubDate>Tue, 25 Oct 2011 11:15:26 -0800</pubDate>
    </item>
    <item>
      <title>Re: GUI Qt for C++</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423947/423960/ReadMessage.aspx#423960</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/dede/"&gt;dede&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/423947/423960/ReadMessage.aspx#423960"&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;Hi &lt;br /&gt;
First of all Qt is not a compiler, it's just an IDE, it's based on the gcc, yet you can use borland C++ or MS VC++ once you have Qt onboard.&lt;br /&gt;
&lt;br /&gt;
I'm not sure what do you mean by "do all the work". &lt;br /&gt;
In Visual Studio, of course you have to assign a path for the Qt Libs in case you are gonna code in MSVC++ editor. you can do that from the project settings.&lt;br /&gt;
&lt;br /&gt;
It will teach you all you need about using Qt under Linux and/or Windows platforms.&lt;br /&gt;
&lt;br /&gt;
dede&lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423947/423960/ReadMessage.aspx#423960</guid>
      <pubDate>Thu, 02 Jun 2011 10:43:02 -0800</pubDate>
    </item>
    <item>
      <title>Re: What exactly is a word ?</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423675/423870/ReadMessage.aspx#423870</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/HK_MP5KPDW/"&gt;HK_MP5KPDW&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/423675/423870/ReadMessage.aspx#423870"&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;Well, &lt;a href="http://www.lmgtfy.com/?q=computer+word+definition"&gt;&lt;span style="text-decoration: underline;"&gt;a simple search&lt;/span&gt;&lt;/a&gt; can enable easily find this out.&lt;br /&gt;
&lt;br /&gt;
The very first result from that is &lt;a href="http://en.wikipedia.org/wiki/Computer_word"&gt;&lt;span style="text-decoration: underline;"&gt;this&lt;/span&gt;&lt;/a&gt;.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423675/423870/ReadMessage.aspx#423870</guid>
      <pubDate>Tue, 17 May 2011 14:03:54 -0800</pubDate>
    </item>
    <item>
      <title>Re: stop iteration inside a for loop</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423811/423834/ReadMessage.aspx#423834</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/423811/423834/ReadMessage.aspx#423834"&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;You can use the same break statement used in a while loop. That will cause the for() loop to be exited.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423811/423834/ReadMessage.aspx#423834</guid>
      <pubDate>Mon, 16 May 2011 04:40:09 -0800</pubDate>
    </item>
    <item>
      <title>Re: how to create .h header files for .c files?</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423828/423833/ReadMessage.aspx#423833</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/423828/423833/ReadMessage.aspx#423833"&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;Header file contains function prototypes, structure declarations, constant definitions, like #define.&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
//
// MODULE1.H FILE:
//
void func1 (int x);
float func2 (float y);
int func3 (char a);
&lt;/pre&gt;&lt;br /&gt;
&lt;span style="color: Blue;"&gt;Source file contains function bodies. It is preferred that names of both files are same, but they have different extension, like MODULE1.H and MODULE1.C:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
//
// MODULE1.C FILE:
//
#include "MODULE1.H"

void func1 (int x)
{
    // ... your implementation here ...
}

float func2 (float y)
{
    // ... your implementation here ...
}

int func3 (char a)
{
    // ... your implementation here ...
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: Blue;"&gt;After these TWO files are done they are used in a project - or you call it a large program. Usually, the development environment which you use has the ability to insert files into project. You need to insert both files into projects and then just "#include "&amp;lt;small_prog&amp;gt;.h"" into other C files of the project where you need those functions.&lt;br /&gt;
&lt;br /&gt;
If you do not have an environment (like Dev-C++ or Visual C++ or something else...) then "include &amp;lt;small_prog&amp;gt;.c" is the way to go.&lt;br /&gt;
&lt;br /&gt;
There are few other ways: like to compile the C file into .OBJ file and then use LINK tool to build the full program. It is usually done by the environment, but you can also do it manually - using command line tools.&lt;br /&gt;
&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423828/423833/ReadMessage.aspx#423833</guid>
      <pubDate>Mon, 16 May 2011 04:37:04 -0800</pubDate>
    </item>
    <item>
      <title>Re: Linked List issue / debugging</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423798/423810/ReadMessage.aspx#423810</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/423798/423810/ReadMessage.aspx#423810"&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;Looking very closely you can see that 'case 8' is missing one line (compare it with other cases) - something about the size...&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423798/423810/ReadMessage.aspx#423810</guid>
      <pubDate>Sun, 15 May 2011 04:33:06 -0800</pubDate>
    </item>
    <item>
      <title>Re: Help with strncpy - crypt code</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423796/423804/ReadMessage.aspx#423804</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/423796/423804/ReadMessage.aspx#423804"&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; glad to help out if I can.  there are folks here who know their stuff, but I'm more of a hobbyist. :)&lt;br /&gt;
&lt;br /&gt;
try casting malloc; it's been a while since I've done any programming on a regular basis and can't recall all of the particulars.  I don't use Borland, and didn't run into that problem.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
if((tmp = (char *)malloc((strlen(src) * 3) + 1)) != NULL) {
   ...
}&lt;/pre&gt; &lt;br /&gt;
&lt;br /&gt;
welcome to the board.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423796/423804/ReadMessage.aspx#423804</guid>
      <pubDate>Sun, 15 May 2011 00:35:29 -0800</pubDate>
    </item>
    <item>
      <title>Re: Why does it do what it does</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423799/423800/ReadMessage.aspx#423800</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/423799/423800/ReadMessage.aspx#423800"&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're actually entering 1/5, cin &amp;gt;&amp;gt; gal will go into a fail state upon reading the / as gal is a double and / is not.  you might try adding something like below to give it a quick check.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;... bits of code
cin &amp;gt;&amp;gt; gal;

if(cin.fail()) {
   // take some action;
}

... bits of code&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423799/423800/ReadMessage.aspx#423800</guid>
      <pubDate>Sat, 14 May 2011 23:37:21 -0800</pubDate>
    </item>
    <item>
      <title>Linked List issue / debugging</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423798/423798/ReadMessage.aspx#423798</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/ghostfacelz/"&gt;ghostfacelz&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/423798/423798/ReadMessage.aspx#423798"&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 have been struggling with this problem for about 2 days now and I just cant figure out what the problem is.&lt;br /&gt;
I am making a linked list that points to a char array at different addresses.&lt;br /&gt;
So for the 8byte linked list, it points to an address every 8 bytes.&lt;br /&gt;
link lists 32bytes, 64bytes etc also follow the same pattern.&lt;br /&gt;
Here is the code that is giving me issues:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
void CMemoryPoolManager::initializeLinkedList(char MM_pool[], int chunks, int chunkSize, int offset)
  {
	MemoryBlock current;
	MemoryBlock *pCurrent = NULL;
        pCurrent = &amp;amp;current;
	for (int i=0; i &amp;lt; chunks; i++)
	{
		pCurrent = (MemoryBlock *)&amp;amp;MM_pool[sizeof(CMemoryPoolManager) +1 + (i * chunkSize) + offset];
		pCurrent-&amp;gt;pNext = NULL;
		pCurrent-&amp;gt;pPrevious = NULL;
		pCurrent-&amp;gt;bInUse = false;

		switch (chunkSize)
		{
		case 8:
			pCurrent-&amp;gt;pNext = p8Byte;
			if (p8Byte != NULL)
				p8Byte-&amp;gt;pPrevious = pCurrent;
			p8Byte = pCurrent;
			break;
		case 32:
			pCurrent-&amp;gt;siSize = 32;
			pCurrent-&amp;gt;pNext = p32Byte;
			if (p32Byte != NULL)
				p32Byte-&amp;gt;pPrevious = pCurrent;
			p32Byte = pCurrent;
			break;
		case 64:
			pCurrent-&amp;gt;siSize = 64;
			pCurrent-&amp;gt;pNext = p64Byte;
			if (p64Byte != NULL)
				p64Byte-&amp;gt;pPrevious = pCurrent;
			p64Byte = pCurrent;
			break;

		}
	}
}
&lt;/pre&gt;&lt;br /&gt;
MemoryBlock is a struct in CMemoryPoolManager that holds the pointers next and previous&lt;br /&gt;
size is just for testing disregard that.&lt;br /&gt;
and the p##Byte are the linked lists inside CMemoryPoolManager&lt;br /&gt;
the line: &lt;br /&gt;
&lt;pre class="sourcecode"&gt;
pCurrent = (MemoryBlock *)&amp;amp;MM_pool[sizeof(CMemoryPoolManager) +1 + (i * chunkSize) + offset];
&lt;/pre&gt;&lt;br /&gt;
gets the position of where to create the next "node".&lt;br /&gt;
&lt;br /&gt;
Now on to the question / problem.&lt;br /&gt;
When creating the 8byte list,it doesnt link properly.&lt;br /&gt;
When it hits the "case 8:" line pCurrent-&amp;gt;pNext changes by itself and subsequently changes the p8Byte links. So it never creates a proper list.&lt;br /&gt;
What really makes things weird is that the 32 and 64 byte lists are made correctly with no issues. Its the same code, it follows the same pattern, but the 8Byte list just doesnt work for whatever reason!&lt;br /&gt;
I have no clue as to why...ive tried a variety of things and nothing seems to help.&lt;br /&gt;
Can anyone suggest anything to try or see what the issue might be?&lt;br /&gt;
Any help at all would be GREATLY appreciated!!&lt;br /&gt;
Thanks!&lt;br /&gt;
&lt;br /&gt;
=Ghost=&amp;gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423798/423798/ReadMessage.aspx#423798</guid>
      <pubDate>Sat, 14 May 2011 10:49:39 -0800</pubDate>
    </item>
    <item>
      <title>Re: literal instructions</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423775/423782/ReadMessage.aspx#423782</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/423775/423782/ReadMessage.aspx#423782"&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 very hard to do. You need to parse (break) the formula text into elements and operators. Elements can be a function name and parameters (like pow(..) or sqrt(...)) or a constant values (like 4.8374). Operators are mathematical operations, like * (MULTIPLY), \ (DIVIDE), + (ADD), - (SUBTRACT). There is an algorithm for this kind of thing:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://en.wikipedia.org/wiki/Polish_notation"&gt;http://en.wikipedia.org/wiki/Polish_notation&lt;/a&gt;&lt;br /&gt;
&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423775/423782/ReadMessage.aspx#423782</guid>
      <pubDate>Fri, 13 May 2011 03:59:38 -0800</pubDate>
    </item>
    <item>
      <title>Memory Pool &amp; char array</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423737/423737/ReadMessage.aspx#423737</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/ghostfacelz/"&gt;ghostfacelz&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/423737/423737/ReadMessage.aspx#423737"&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;Hi, &lt;br /&gt;
I was recently assigned a project and I'm looking for a little advice.&lt;br /&gt;
I have to implement a memory manager that has a char array for a memory pool.&lt;br /&gt;
So what I have concepted out was to segment the pool up into variable sized chunks, using the begining of the mempool to hold the location of the chunks as well as if they are being used.&lt;br /&gt;
I think its a fairly good solution as the conditions are that no other static or global variable may be created (the reason I went with this route was the hint that if we need to save data, we need to make it fit in the pool)&lt;br /&gt;
&lt;br /&gt;
In any case on to my questions...&lt;br /&gt;
1)Anyone have any experience with variable pools, and would this approach theoretically work? I wouldnt want to get a day or two into it and hit a major design flaw that requires scrapping the whole project.&lt;br /&gt;
&lt;br /&gt;
2)Can a character array store addresses of other portions of the same array, if so, can you offer some suggested reading on how to go about doing so (syntax-wise)?&lt;br /&gt;
&lt;br /&gt;
Any advice would be greatly appreciated!!&lt;br /&gt;
&lt;br /&gt;
Thanks!&lt;br /&gt;
-G&lt;br /&gt;
=Ghost=&amp;gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423737/423737/ReadMessage.aspx#423737</guid>
      <pubDate>Tue, 10 May 2011 14:43:38 -0800</pubDate>
    </item>
    <item>
      <title>Re: Declaring Strings</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423666/423669/ReadMessage.aspx#423669</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/423666/423669/ReadMessage.aspx#423669"&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;char a[] = "hello world";&lt;br /&gt;
&lt;br /&gt;
you can that because the compiler knows how much space to allocate for the string "hello world."&lt;br /&gt;
&lt;br /&gt;
char a[];&lt;br /&gt;
a = "hello world";&lt;br /&gt;
&lt;br /&gt;
C won't allow aggregate assignment; you've got an array of chars and a string, which aren't exactly the same thing.  you've also got an unknown size - the compiler doesn't know much space to allocate to a.&lt;br /&gt;
&lt;br /&gt;
char a[80];&lt;br /&gt;
strcpy(a, "hello world");&lt;br /&gt;
&lt;br /&gt;
An interesting feature of C though is you can assign structs.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
typedef struct {
   char a[40];
} test;

test t1 = { "hello world" }, t2 = t1;

puts(t1.a);
puts(t2.a);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
HTH&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423666/423669/ReadMessage.aspx#423669</guid>
      <pubDate>Fri, 06 May 2011 10:31:08 -0800</pubDate>
    </item>
    <item>
      <title>Re: How to Convert Integer into a String then turn it to Floating poin</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423630/423634/ReadMessage.aspx#423634</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/423630/423634/ReadMessage.aspx#423634"&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;num3 = atoi(str1);&lt;br /&gt;
&lt;br /&gt;
atoi will truncate your float to an integer first.  if you want/need a float, use atof.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
   printf("Enter first number: ");
   scanf("%d",&amp;amp;num1);
   printf("Enter second number: ");
   scanf("%d",&amp;amp;num2);

   sprintf(str1, "%d.%d", num1, num2);
   sscanf(str1, "%f", &amp;amp;num3);
   
   printf("%.2f", num3);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
another way to more or less do the same thing&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423630/423634/ReadMessage.aspx#423634</guid>
      <pubDate>Wed, 04 May 2011 21:03:06 -0800</pubDate>
    </item>
    <item>
      <title>Re: the position after the last element of an array</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423554/423569/ReadMessage.aspx#423569</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/423554/423569/ReadMessage.aspx#423569"&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;Not the best book you got - get another one.&lt;br /&gt;
This pointer is invalid in most cases. The problem is that this pointer will cause undefined behaviour. This means that pointer may be valid and may be invalid depending on some factors, like compiling a program with optimizations switched on or off. Or the array was allocated on stack or on heap - or other kinds of factors. The quality code should never even allow the undefined behaviour. So, just accept it that this pointer is invalid.&lt;br /&gt;
&lt;br /&gt;
I would like to add something here. Maybe book is talking about a special kind of array in C - it is called a string. A string is array of characters terminated by a character with binary code zero (character null). A lot of 1st "graders" get confused here. For example take string "HELLO" - how many elements in that array? For untrained eye - it has 5 elements. But that eye did not count that terminating null. With that null - the string array has 6 elements. So, if the book was talking about that kind of situation - pointer to the element following the LAST STRING ELEMENT - then that statement IS CORRECT if we talking about the valid characters (not null). Here is that example in visual aid:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
    +---+---+---+---+---+------+--------------------------+
    | &lt;span style="color: Green;"&gt;H&lt;/span&gt; | &lt;span style="color: Green;"&gt;E&lt;/span&gt; | &lt;span style="color: Green;"&gt;L&lt;/span&gt; | &lt;span style="color: Green;"&gt;L&lt;/span&gt; | &lt;span style="color: Green;"&gt;O&lt;/span&gt; | &lt;span style="color: Red;"&gt;null&lt;/span&gt; | .... undefined behaviour |
    |   |   |   |   |   |      |      begins here         |
    +---+---+---+---+---+------+--------------------------+
                        |      |
 Pointer still valid --&amp;gt;|      |
         Pointer is invalid --&amp;gt;|
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423554/423569/ReadMessage.aspx#423569</guid>
      <pubDate>Sun, 01 May 2011 04:38:43 -0800</pubDate>
    </item>
    <item>
      <title>Re: Best Book/Resources To Learn C++?</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423496/423531/ReadMessage.aspx#423531</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/423496/423531/ReadMessage.aspx#423531"&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;I do not understand your question "in which language compilers are written?". Compilers are EXE files - they can be written in any language. There is no connection between language compiler is written with and language which compiler "understands". C++ compiler can be written using BASIC - it will be slower, but it will work.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423496/423531/ReadMessage.aspx#423531</guid>
      <pubDate>Fri, 29 Apr 2011 04:24:50 -0800</pubDate>
    </item>
    <item>
      <title>Re: Help with Pointers to Array of Struct in C++</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423382/423458/ReadMessage.aspx#423458</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/423382/423458/ReadMessage.aspx#423458"&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 I recall, you can use &lt;br /&gt;
&lt;br /&gt;
cout &amp;lt;&amp;lt; ( *(carsPtr + 1) ).carMake;&lt;br /&gt;
or&lt;br /&gt;
cout &amp;lt;&amp;lt; (carsPtr + 1)-&amp;gt;carMake;&lt;br /&gt;
&lt;br /&gt;
dunno which is prefered though... it's been way too long since I coded anything on a regular basis. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423382/423458/ReadMessage.aspx#423458</guid>
      <pubDate>Mon, 25 Apr 2011 19:26:19 -0800</pubDate>
    </item>
    <item>
      <title>Re: Help with reading a file in C, please.</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423389/423446/ReadMessage.aspx#423446</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/423389/423446/ReadMessage.aspx#423446"&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;This code will not work. 190 is approximate # of lines in file - not characters per line. And lines will not be the same length, so reading constantly by 190 characters will skip some short lines and lines will be loaded not from the beginning of each line, but from some place in file which is divisible by 190 bytes.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423389/423446/ReadMessage.aspx#423446</guid>
      <pubDate>Mon, 25 Apr 2011 04:16:12 -0800</pubDate>
    </item>
    <item>
      <title>Moving files and directories in C++?</title>
      <link>http://www.programmersheaven.com/mb/ConLunix/423433/423433/ReadMessage.aspx#423433</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/Sephiroth/"&gt;Sephiroth&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/ConLunix/423433/423433/ReadMessage.aspx#423433"&gt;new message&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/ConLunix/Board.aspx"&gt;C/C++ on Linux/Unix&lt;/a&gt; forum.&lt;/p&gt;The topic says it all. I don't have time to wait for the official ext4 defrag utility so I am going to write one that I can use temporarily. Basically, I want the user to specify a partition or directory to be defragmented and have my program move the directory or partition contents to an external HDD or, if it is large enough, temporary directory/partition, then start moving things back in alphabetical order. Since Linux will not fragment files during a move, this should take fragmented files and plop them back together, as well as sorting them alphabetically.&lt;br /&gt;
&lt;br /&gt;
My problem lies within moving stuff using C++. I canot figure out how to do it. All I can find on Google are people taking shortcuts and using the system call to invoke "mv". I want my program to function properly though, with no shortcuts. Can somebody help me figure out how to move a directory-tree, including files, to a specified location? How about just moving individual files?&lt;br /&gt;
&lt;br /&gt;
-&lt;em&gt;&lt;strong&gt;&lt;span style="color: Red;"&gt;S&lt;/span&gt;&lt;span style="color: Purple;"&gt;e&lt;/span&gt;&lt;span style="color: Blue;"&gt;p&lt;/span&gt;&lt;span style="color: Green;"&gt;h&lt;/span&gt;&lt;span style="color: Red;"&gt;i&lt;/span&gt;&lt;span style="color: Purple;"&gt;r&lt;/span&gt;&lt;span style="color: Blue;"&gt;o&lt;/span&gt;&lt;span style="color: Green;"&gt;t&lt;/span&gt;&lt;span style="color: Red;"&gt;h&lt;/span&gt;&lt;/strong&gt;&lt;/em&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/ConLunix/423433/423433/ReadMessage.aspx#423433</guid>
      <pubDate>Sun, 24 Apr 2011 17:19:20 -0800</pubDate>
    </item>
    <item>
      <title>Re: Help with reading a file in C, please.</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423389/423398/ReadMessage.aspx#423398</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/423389/423398/ReadMessage.aspx#423398"&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;Better way would be to use fgets() to read one line of the file and then use strtok() to parse that line using comma separator.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423389/423398/ReadMessage.aspx#423398</guid>
      <pubDate>Sat, 23 Apr 2011 05:56:41 -0800</pubDate>
    </item>
    <item>
      <title>Re: Three C lines On Borland please</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423371/423376/ReadMessage.aspx#423376</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/423371/423376/ReadMessage.aspx#423376"&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;-24 on TC31.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423371/423376/ReadMessage.aspx#423376</guid>
      <pubDate>Fri, 22 Apr 2011 06:55:15 -0800</pubDate>
    </item>
    <item>
      <title>Re: Help w/ input validation in function arrays</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423363/423375/ReadMessage.aspx#423375</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/423363/423375/ReadMessage.aspx#423375"&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;iostream&amp;gt;
#include &amp;lt;iomanip&amp;gt;
using namespace std;
#include &amp;lt;string&amp;gt;

int getEmployeeData (int[], char[], int, float[]);
float calculateGrossPay(char[], float[], int, float[], string[], float*);
void displayEmployeeInfo (int[], string[], int, float[]);
bool tryAgain (char);
bool isValidStatus (char);
//bool isValidID (int);

&lt;span style="color: Green;"&gt;//
// The main idea of these two following functions is to
// validate the text entered by user and then convert that
// to a proper numeric value using atoi() function to
// convert to an integer and atof() - to convert to a float.
// Basically, user enters text at first.
//&lt;/span&gt;
int IsValidFloat(const char text[])
{
	int nDots=0;
	char c;
	&lt;span style="color: Green;"&gt;//
	// Examine each character within text
	//&lt;/span&gt;
	while ((c = *text++) != 0)
	{
		&lt;span style="color: Green;"&gt;//
		// Count the decimal period characters
		//&lt;/span&gt;
		if (c == '.') ++nDots;
		&lt;span style="color: Green;"&gt;//
		// Non-digit character means invalid input
		//&lt;/span&gt;
		else if ((c &amp;lt; '0') || (c &amp;gt; '9')) return 0;
	}
	return (nDots &amp;lt; 2);
}

int IsValidInteger(const char text [])
{
	string s (text); &lt;span style="color: Green;"&gt;// Construct a string object out of text&lt;/span&gt;
	&lt;span style="color: Green;"&gt;//
	// Re-use the float validator and just check if value
	// has a decimal period and if it has - then text is not valid.
	// There should be only digits to indicate an integer.
	//&lt;/span&gt;
	return (IsValidFloat (text) &amp;amp;&amp;amp; (s.find ('.') == string::npos));
}

&lt;span style="color: Green;"&gt;//
// Using these two validators we can write a common function
// to enter both types of values.
//
// prompt:		text to print before input is entered
// IResult:		address of integer value to enter
//				(pass NULL if float value needed)
// FResult:		address of float value to enter
//				(pass NULL if integer value needed)
//
// Do not pass NULL for both IResult and FResult!
// This will force the code into endless loop!
//&lt;/span&gt;
void AskNumericValue (char* prompt, int* IResult, float* FResult)
{
	string value;
	while (prompt) &lt;span style="color: Green;"&gt;// loop until poor user enters valid value&lt;/span&gt;
	{
		&lt;span style="color: Green;"&gt;//
		// Ask the question and get the text
		//&lt;/span&gt;
		cout &amp;lt;&amp;lt; prompt;
		cin &amp;gt;&amp;gt; value;
		&lt;span style="color: Green;"&gt;//
		// If integer wanted - verify and convert as integer
		//&lt;/span&gt;
		if (IResult)
		{
			if (! IsValidInteger (value.c_str ()))
			{
				cout &amp;lt;&amp;lt; "\n-- Please enter integer value.\n";
				continue; &lt;span style="color: Green;"&gt;// &amp;lt;-- go back to enter a while() block again&lt;/span&gt;
			}
			*IResult = atoi (value.c_str ());
			return; &lt;span style="color: Green;"&gt;// Done with int value&lt;/span&gt;
		}
		&lt;span style="color: Green;"&gt;//
		// Same for float
		//&lt;/span&gt;
		if (FResult)
		{
			if (! IsValidFloat (value.c_str ()))
			{
				cout &amp;lt;&amp;lt; "\n-- Please enter float point value.\n";
				continue;
			}
			*FResult = (float) atof (value.c_str ());
			&lt;span style="color: Green;"&gt;//
			// atof() returns double, thus it is ^^^ converted to float
			//&lt;/span&gt;
			return;
		}
	}
}

int main()
{
	const int numEmp = 4;
	int empId[numEmp], size;
	char payrollStat[numEmp];	
	float gross[numEmp];
	float pay[numEmp];
	float totalPay = 0;
	string nameStatus[numEmp];

	size = numEmp;

	getEmployeeData(empId, payrollStat, size, gross);
	&lt;span style="color: Green;"&gt;//
	// Return value up here ^^^ is lost. The value you
	// calculated is returned by 'gross'.
	//&lt;/span&gt;
	calculateGrossPay(payrollStat, gross, size, pay, nameStatus, &amp;amp;totalPay);
	cout &amp;lt;&amp;lt; fixed &amp;lt;&amp;lt; showpoint &amp;lt;&amp;lt; setprecision(2);	
	displayEmployeeInfo (empId, nameStatus, size, pay);

	cout &amp;lt;&amp;lt; "\nTotal Payroll for this month: " &amp;lt;&amp;lt; "$" &amp;lt;&amp;lt; totalPay &amp;lt;&amp;lt; endl;

	system("pause");
	
	return 0;
}

int getEmployeeData (int e[], char ps[], int numEmp, float amt[])
{
	bool vStat;
	bool tAgain;
	char q;
	int x;
	&lt;span style="color: Green;"&gt;//
	// Arrays need to be cleared, so if user quits - proper
	// calculations are done.
	//&lt;/span&gt;
	for (x = 0; x &amp;lt; numEmp; x++)
	{
		ps[x] = 'Q';
		e[x] = 0;
		amt[x] = 0;
	}

	for (x = 0; x &amp;lt; numEmp; x++)
	{
		&lt;span style="color: Green;"&gt;//cout &amp;lt;&amp;lt; "Enter employee ID ====&amp;gt; ";
		//cin &amp;gt;&amp;gt; e[x];&lt;/span&gt;
		AskNumericValue ("Enter employee ID ====&amp;gt; ", &amp;amp;e[x], NULL);

		cout &amp;lt;&amp;lt; "Enter payroll status (s/h/c)====&amp;gt; ";
		cin &amp;gt;&amp;gt; ps[x];
		ps[x] = toupper(ps[x]);
		&lt;span style="color: Green;"&gt;//
		// This ^^^ (passing a char to cin) is not good. Try
		// To enter something like "sss" and you will see that
		// some of following inputs are 'swallowed' by cin.
		// You need to enter a string and then transfer the
		// 1st character into ps[x]. Before the transfer you
		// need to verify that string is indeed "S","H" or "C".
		//&lt;/span&gt;
		vStat = isValidStatus(ps[x]);
		if(vStat == false)
		{
			do
			{
				cout &amp;lt;&amp;lt; "*** Invalid payroll status ***\n";
				cout &amp;lt;&amp;lt; "Do you want to try again or quit?\n";
				cout &amp;lt;&amp;lt; "Type Q or q to quit, any other key to continue: ";
				cin &amp;gt;&amp;gt; q;
				q = toupper(q);
				&lt;span style="color: Green;"&gt;//
				// The 'other key to continue' is kind
				// of asking to press spacebar. Try it.
				// cin ignores empty space (tabs or blanks).
				//&lt;/span&gt;
				tAgain = tryAgain(q);

				if(tAgain == false)
				{
					cout &amp;lt;&amp;lt; "   Re-enter: 's' or 'S' for salaried, 'h' or 'H' for hourly,\n";
					cout &amp;lt;&amp;lt; "   'c' or 'C' for commissioned ====&amp;gt; ";
					cin &amp;gt;&amp;gt; ps[x];
					ps[x] = toupper(ps[x]);	
					vStat = isValidStatus(ps[x]);
				}

			}while (vStat == false &amp;amp;&amp;amp; q != 'Q');
			&lt;span style="color: Green;"&gt;//
			// Quit the for() loop
			//&lt;/span&gt;
			if (q == 'Q') break;
		}

		if(vStat == true)
		{
			char* prompt;
			if (ps[x] == 'S')
			{
				&lt;span style="color: Green;"&gt;//cout &amp;lt;&amp;lt; "Enter monthly salary ====&amp;gt; ";&lt;/span&gt;
				prompt = "Enter monthly salary ====&amp;gt; ";
			}
			else if (ps[x] == 'H')
			{
				&lt;span style="color: Green;"&gt;//cout &amp;lt;&amp;lt; "Enter number of hours worked this month ====&amp;gt; ";&lt;/span&gt;
				prompt = "Enter number of hours worked this month ====&amp;gt; ";
			}
			else if (ps[x] == 'C')
			{
				&lt;span style="color: Green;"&gt;//cout &amp;lt;&amp;lt; "Enter total sales for this month ====&amp;gt; ";&lt;/span&gt;
				prompt = "Enter total sales for this month ====&amp;gt; ";
			}
	
			&lt;span style="color: Green;"&gt;//cin &amp;gt;&amp;gt; amt[x];&lt;/span&gt;
			AskNumericValue (prompt, NULL, &amp;amp;amt[x]);
			cout &amp;lt;&amp;lt; "\n";
		}
	}
	&lt;span style="color: Green;"&gt;//return (int) amt[x]; // Why return it if never used?
	//
	// Also, the compiler shows the loss of data up here ^^^, because
	// the return type is int and amt[x] is float, so if you return
	// 3762.94 - you get 3762 from the function, so .94 is lost. But,
	// the returned value is not used anyway - just FYI.
	//
	// P.S. Another problem here -- 'x' reached a value of 4 now, because
	// for() loop ended, so amt[x] is returning a value beyond the last
	// value in that array - the last valid index for the array is 3.
	// I will simply return 0 here - it is not used anyway.&lt;/span&gt;
	return 0;
}

float calculateGrossPay (char pStat[], float pay[] , int numEmp, float tot[], string nStat[], float* totalP)
{
	int y;
	*totalP = 0; // Clear total
	for (y = 0; y &amp;lt; numEmp; y++)
	{
		if (pStat[y] == 'Q') break; &lt;span style="color: Green;"&gt;// Do not calc more if 'Q' encountered&lt;/span&gt;

		if (pStat[y] == 'S')
		{
			nStat[y] = "Salaried    ";
			tot[y] = pay[y];
			*totalP += tot[y];
		}
		if (pStat[y] == 'H')
		{
			nStat[y] = "Hourly      ";
			tot[y] = pay[y] * 18.75f; // &amp;lt;-- float constants must have 'f'
			*totalP += tot[y];
		}
		if (pStat[y] == 'C')
		{
			nStat[y] = "Commissioned";
			tot[y] = (pay[y] * 0.06f) + 1000.00f;
			*totalP += tot[y];
		}
	}
	return *totalP;
}

void displayEmployeeInfo (int id[], string payS[], int numEmp, float gPay[])
{
	cout &amp;lt;&amp;lt; "Employee ID\t" &amp;lt;&amp;lt; "Payroll Status\t" &amp;lt;&amp;lt; "GrossPay\n";
	cout &amp;lt;&amp;lt; "-----------\t" &amp;lt;&amp;lt; "--------------\t" &amp;lt;&amp;lt; "--------\n";
	for (int z = 0; z &amp;lt; numEmp; z++)
	{
		if (id[z] == 0) break; &lt;span style="color: Green;"&gt;// In case of quitting&lt;/span&gt;
		cout &amp;lt;&amp;lt; id[z] &amp;lt;&amp;lt; "\t\t" &amp;lt;&amp;lt; payS[z] &amp;lt;&amp;lt; "\t" &amp;lt;&amp;lt; "$" &amp;lt;&amp;lt; gPay[z] &amp;lt;&amp;lt; endl;
	}
}

bool isValidStatus (char stat)
{
	if(stat == 'S' || stat == 'H' || stat == 'C')
		return true;
	else
		return false;
}

bool tryAgain (char q)
{
	if(q == 'Q')
		return true;
	else 
		return false;
}
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423363/423375/ReadMessage.aspx#423375</guid>
      <pubDate>Fri, 22 Apr 2011 06:47:04 -0800</pubDate>
    </item>
    <item>
      <title>Re: C++ Strings, instream, delete duplicates</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423319/423335/ReadMessage.aspx#423335</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/423319/423335/ReadMessage.aspx#423335"&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;Flawed?  It's not my assignment; bridge the gap between the snippit and what you need to do, which would seem to be handling files, functions, mixed case, and such. :)&lt;br /&gt;
&lt;br /&gt;
If you're having trouble, post your attempt(s).&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423319/423335/ReadMessage.aspx#423335</guid>
      <pubDate>Wed, 20 Apr 2011 13:11:40 -0800</pubDate>
    </item>
    <item>
      <title>Re: C++ Strings, instream, delete duplicates</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/423319/423320/ReadMessage.aspx#423320</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/423319/423320/ReadMessage.aspx#423320"&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 won't really get into functions or files, but to remove the dups, you might try fiddling around with something like&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;algorithm&amp;gt;

int main() {

   std::string strs[] = { "Google", "Yahoo", "Lie", "Ggy" };   
   
   for(int i=0; i &amp;lt; 4; ++i) {
      strs[i].erase(std::unique(strs[i].begin(), strs[i].end()), strs[i].end());
      std::cout &amp;lt;&amp;lt; strs[i] &amp;lt;&amp;lt; std::endl;
   }
   
   return 0;
}&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/423319/423320/ReadMessage.aspx#423320</guid>
      <pubDate>Tue, 19 Apr 2011 20:46:57 -0800</pubDate>
    </item>
    <item>
      <title>Best free C and C++ programming courses online</title>
      <link>http://www.programmersheaven.com/article/107645-Best+free+C+and+C+++programming+courses+online/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/msaqib/"&gt;msaqib&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/article/107645-Best+free+C+and+C%2b%2b+programming+courses+online/info.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;This article shows you a list of C and C++ programming courses freely available online on different university websites in the form of OpenCourseware.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/article/107645-Best+free+C+and+C%2b%2b+programming+courses+online/info.aspx</guid>
      <pubDate>Mon, 18 Apr 2011 07:31:59 -0800</pubDate>
    </item>
    <item>
      <title>Re: Division in C programming. plz help</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423253/423260/ReadMessage.aspx#423260</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/423253/423260/ReadMessage.aspx#423260"&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;1st part is correct, but you did not check the 2nd part of condition. When value is even - last bit is always zero, so a simple code will check for that:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
if ((value%3 == 0) &amp;amp;&amp;amp; (value&amp;amp;1 == 0))
{
    &lt;span style="color: Green;"&gt;// value is both even and divisible by 3&lt;/span&gt;
}
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423253/423260/ReadMessage.aspx#423260</guid>
      <pubDate>Sun, 17 Apr 2011 05:08:50 -0800</pubDate>
    </item>
    <item>
      <title>Re: Scheduling A Function To Be Called Every N Milliseconds?</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423041/423130/ReadMessage.aspx#423130</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/423041/423130/ReadMessage.aspx#423130"&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;If you don't mind a rough timer, you might try something like&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
int scheduledCall(void) {

   static int count = 0;

   /* function task(s) */

   return (count++);
}

int main(void) {

   time_t t1, t2;
   long nsecs = 1; // ~ 1000 ms

   while(scheduledCall() &amp;lt; 500) {
      t1 = time(NULL);
      do { t2 = time(NULL); } while((t1 + nsecs) &amp;gt; t2);
   }

   return 0;
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
You could also keep a local counter instead of scheduledCall returning a value.&lt;br /&gt;
&lt;br /&gt;
HTH&lt;br /&gt;
          &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423041/423130/ReadMessage.aspx#423130</guid>
      <pubDate>Fri, 08 Apr 2011 17:23:14 -0800</pubDate>
    </item>
    <item>
      <title>Porting an application from C++ Builder to Qt Creator</title>
      <link>http://www.programmersheaven.com/article/107504-Porting+an+application+from+C+++Builder+to+Qt+Creator/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bilderbikkel/"&gt;bilderbikkel&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/article/107504-Porting+an+application+from+C%2b%2b+Builder+to+Qt+Creator/info.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;This article describes how to port a C++ Builder (6.0) application to Qt Creator. The main advantage of doing so, is that the Windows-only application becomes cross-platform.
 
This article uses the architecture described in the article Thinking Qt 1: general.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/article/107504-Porting+an+application+from+C%2b%2b+Builder+to+Qt+Creator/info.aspx</guid>
      <pubDate>Wed, 06 Apr 2011 07:05:49 -0800</pubDate>
    </item>
    <item>
      <title>Re: "Decompliling" C++ Code? Possible To Get Into An Exe File</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423042/423045/ReadMessage.aspx#423045</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/423042/423045/ReadMessage.aspx#423045"&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;You need a good debugger for this. IDA PRO comes to mind, but it cost money. Try to get a trial version - it may work for 30 days or so. Best free debuffer for Win32 is OLLYDBG. Google for it and get version 1.1 - version 2.0 is there too, but it is too fresh.&lt;br /&gt;
&lt;br /&gt;
Just load EXE into debugger and step through code. Of course, you need to know a little assembler for it.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423042/423045/ReadMessage.aspx#423045</guid>
      <pubDate>Wed, 06 Apr 2011 04:37:06 -0800</pubDate>
    </item>
    <item>
      <title>Re: a do-while calculator</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422852/422950/ReadMessage.aspx#422950</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/422852/422950/ReadMessage.aspx#422950"&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;no worries. :)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/422852/422950/ReadMessage.aspx#422950</guid>
      <pubDate>Fri, 01 Apr 2011 19:02:09 -0800</pubDate>
    </item>
    <item>
      <title>Re: do while loop</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422935/422949/ReadMessage.aspx#422949</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/422935/422949/ReadMessage.aspx#422949"&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 the code you've submitted is what you're using, then you're using uninitialized data in x, y, start, and stop.&lt;br /&gt;
&lt;br /&gt;
while(x = stop); this isn't what you'd want; your comparison will be something like != (not equal to), == (equal to), &amp;gt;= (greater / equal to), or &amp;lt;= (less than equal to).  &lt;br /&gt;
&lt;br /&gt;
y looks like it should be computed within the do-while if you're incrementing x.&lt;br /&gt;
&lt;br /&gt;
what is your program supposed to do? &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/422935/422949/ReadMessage.aspx#422949</guid>
      <pubDate>Fri, 01 Apr 2011 19:01:18 -0800</pubDate>
    </item>
    <item>
      <title>Re: C++ Tutorials</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422941/422947/ReadMessage.aspx#422947</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/422941/422947/ReadMessage.aspx#422947"&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;Forums are pretty good sources; however, many members will tend to ignore topics if they lack effort, involve a lengthy program when there is a problem with one line or code block, and/or lack code tags.&lt;br /&gt;
&lt;br /&gt;
The more detailed and specific you are, the better off you'll be within the various communites.&lt;br /&gt;
Good luck. :)&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/422941/422947/ReadMessage.aspx#422947</guid>
      <pubDate>Fri, 01 Apr 2011 18:31:46 -0800</pubDate>
    </item>
    <item>
      <title>Re: do-while array</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422919/422946/ReadMessage.aspx#422946</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/422919/422946/ReadMessage.aspx#422946"&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;testScore should check for a "sentinel" value; for example, if you prompt your user to enter data or -1 to quit, then testScore should test against -1.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
do {
   cout &amp;lt;&amp;lt; "Enter a test score (-1) to quit: ";
   cin &amp;gt;&amp;gt; testScore;

   // some something with testScore if it's not -1

} while(testScore != -1);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
As far as the two arrays go, it's not clear what you're trying to accomplish in terms of how they relate to testScore if at all. &lt;br /&gt;
&lt;br /&gt;
You *can eliminate* system("pause") by using&lt;br /&gt;
while(cin.get() != '\n'){}&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/422919/422946/ReadMessage.aspx#422946</guid>
      <pubDate>Fri, 01 Apr 2011 18:16:15 -0800</pubDate>
    </item>
    <item>
      <title>Re: I need some Help :/</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422920/422945/ReadMessage.aspx#422945</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/422920/422945/ReadMessage.aspx#422945"&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 various forums are a good place to start; mill over the topics and see which language(s) interest you.  The homepage has (or had) links to sample source codes as well.&lt;br /&gt;
&lt;br /&gt;
When you're ready, check out &lt;a href="http://www.thefreecountry.com/compilers"&gt;http://www.thefreecountry.com/compilers&lt;/a&gt; for "freeware" compilers.&lt;br /&gt;
&lt;br /&gt;
HTH&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/422920/422945/ReadMessage.aspx#422945</guid>
      <pubDate>Fri, 01 Apr 2011 18:05:21 -0800</pubDate>
    </item>
    <item>
      <title>Re: how to create an array of struct?</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422895/422944/ReadMessage.aspx#422944</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/422895/422944/ReadMessage.aspx#422944"&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;Do you mean a dynamic 2D array?&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
typedef struct {
   int x;
} testing;

...

testing **array;
array = malloc(sizeof(*array) * num_of_rows);

loop(...)
   array[row] = malloc(sizeof(**array) * num_of_cols)

array[row][col].x = some_value;

...

loop(start &amp;lt; num_rows) 
   free(array[start]);
...

free(array);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
It's been a while, but I *think* it's something like that. &lt;br /&gt;
HTH&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/422895/422944/ReadMessage.aspx#422944</guid>
      <pubDate>Fri, 01 Apr 2011 18:00:21 -0800</pubDate>
    </item>
    <item>
      <title>Create a web application from a desktop application</title>
      <link>http://www.programmersheaven.com/article/107505-Create+a+web+application+from+a+desktop+application/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bilderbikkel/"&gt;bilderbikkel&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/article/107505-Create+a+web+application+from+a+desktop+application/info.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;This article describes how to create a Wt web application from a desktop application, leaving both to be used.
 
This article uses the architecture described in the article Thinking Qt 1: general and Thinking Wt 1: general.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/article/107505-Create+a+web+application+from+a+desktop+application/info.aspx</guid>
      <pubDate>Wed, 30 Mar 2011 03:02:44 -0800</pubDate>
    </item>
    <item>
      <title>Porting an application from C++ Builder to Qt Creator</title>
      <link>http://www.programmersheaven.com/article/107504-Porting+an+application+from+C+++Builder+to+Qt+Creator/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bilderbikkel/"&gt;bilderbikkel&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/article/107504-Porting+an+application+from+C%2b%2b+Builder+to+Qt+Creator/info.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;This article describes how to port a C++ Builder (6.0) application to Qt Creator. The main advantage of doing so, is that the Windows-only application becomes cross-platform.
 
This article uses the architecture described in the article Thinking Qt 1: general.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/article/107504-Porting+an+application+from+C%2b%2b+Builder+to+Qt+Creator/info.aspx</guid>
      <pubDate>Wed, 30 Mar 2011 03:01:19 -0800</pubDate>
    </item>
    <item>
      <title>Thinking Qt 1: general</title>
      <link>http://www.programmersheaven.com/article/107503-Thinking+Qt+1:+general/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bilderbikkel/"&gt;bilderbikkel&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/article/107503-Thinking+Qt+1%3a+general/info.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;This article shows one way to think about program architecture when using the Qt library. Because I use this program architecture also when using the Wt library, this article is very similar to Thinking Wt 1: general. Following this architecture results in an easy cross-platform deployment of both a desktop and a web application.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/article/107503-Thinking+Qt+1%3a+general/info.aspx</guid>
      <pubDate>Wed, 30 Mar 2011 03:00:06 -0800</pubDate>
    </item>
    <item>
      <title>Thinking Wt 4: polishing a TicTacToe game</title>
      <link>http://www.programmersheaven.com/article/106922-Thinking+Wt+4:+polishing+a+TicTacToe+game/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bilderbikkel/"&gt;bilderbikkel&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/article/106922-Thinking+Wt+4%3a+polishing+a+TicTacToe+game/info.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;This article shows the way to improve the looks of a TicTacToe game when using the C++ Wt library for developing interactive web applications.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/article/106922-Thinking+Wt+4%3a+polishing+a+TicTacToe+game/info.aspx</guid>
      <pubDate>Wed, 30 Mar 2011 02:58:03 -0800</pubDate>
    </item>
    <item>
      <title>C++ exercise: a foolproof function</title>
      <link>http://www.programmersheaven.com/article/100012-C+++exercise:+a+foolproof+function/info.aspx</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/bilderbikkel/"&gt;bilderbikkel&lt;/a&gt; submitted a new &lt;a href="http://www.programmersheaven.com/article/100012-C%2b%2b+exercise%3a+a+foolproof+function/info.aspx"&gt;article&lt;/a&gt;.&lt;/p&gt;Exercise to write a foolproof C++ function. This appears to be tougher than at first sight.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/article/100012-C%2b%2b+exercise%3a+a+foolproof+function/info.aspx</guid>
      <pubDate>Wed, 30 Mar 2011 02:57:00 -0800</pubDate>
    </item>
    <item>
      <title>Re: a do-while calculator</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422852/422855/ReadMessage.aspx#422855</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/422852/422855/ReadMessage.aspx#422855"&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'm not quite sure what you're wanting to do in terms of the two egg shells, but maybe this will help.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
...
#include &amp;lt;cmath&amp;gt;  // or math.h
#include &amp;lt;cctype&amp;gt; // or ctype.h
...

int main(void) {
   ...
   char choice;

   do {

      cout &amp;lt;&amp;lt; "Enter operator (+, -, /, *): ";
      cin &amp;gt;&amp;gt; choice; while(cin.get() != '\n'){}

      switch(tolower(choice)) {
         case '+' : // do something
                    break;
         case '-' : // do something
                    break;
         case '/' : // do something
                    break;
         case '*' : // do something
                    break;
         case 'q' : cout &amp;lt;&amp;lt; "the end"; 
                    break;
         default  : cout &amp;lt;&amp;lt; choice &amp;lt;&amp;lt; " is not a valid operator";
      }

   } while(tolower(choice)) != 'q');
   ...
}&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/422852/422855/ReadMessage.aspx#422855</guid>
      <pubDate>Tue, 29 Mar 2011 12:29:21 -0800</pubDate>
    </item>
    <item>
      <title>Re: How to know if a thread is finished and wait for it if it isn't</title>
      <link>http://www.programmersheaven.com/mb/mfc_coding/422791/422797/ReadMessage.aspx#422797</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/mfc_coding/422791/422797/ReadMessage.aspx#422797"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/mfc_coding/Board.aspx"&gt;C++ MFC&lt;/a&gt; forum.&lt;/p&gt;&lt;span style="color: Blue;"&gt;WaitForSingleObject will block the waiting thread until working thread finishes. The return code you got may be due to a very fast working thread - you call Wait... at the time when thread is ALREADY DONE! If your main thread (or the one which starts the working thread) must be running and not waiting - then WaitForSingleObject is not the way to use in this case. There are a couple of ways to let know that thread is done: use SetEvent function or post a custom  message if you have HWND to post it to. These things are done at the end of the thread code:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
DWORD WINAPI ThreadCode (PVOID lparam)
{
	&lt;span style="color: Green;"&gt;// your code here...&lt;/span&gt;

	::SetEvent (...); &lt;span style="color: Green;"&gt;// or ::PostMessage();&lt;/span&gt;
	return 0;
}
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/mfc_coding/422791/422797/ReadMessage.aspx#422797</guid>
      <pubDate>Sun, 27 Mar 2011 04:19:14 -0800</pubDate>
    </item>
    <item>
      <title>Re: how to read and write  file faster?</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/422520/422783/ReadMessage.aspx#422783</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/422520/422783/ReadMessage.aspx#422783"&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;When dealing with a single hard drive - multithreading may be slower. No matter how many CPU or cores you have - a single physical drive may cause excessive wear on the drive and slow processing.&lt;br /&gt;
&lt;br /&gt;
Consider this: two threads read two files, separated physically by some amount of sectors. The hard drive heads must move to the 1st file and read the part of it, then next thread comes and heads move to 2nd file sectors, then process repeats - probably a lot of times - depends on a size of the part of the file being loaded. Since there is only one set of drive heads and it cannot be really shared at run-time (like CPU cores) - some thread always will wait until other thread is moving these heads.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/422520/422783/ReadMessage.aspx#422783</guid>
      <pubDate>Sat, 26 Mar 2011 05:06:22 -0800</pubDate>
    </item>
    <item>
      <title>Re: strings and arrays task</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/422752/422759/ReadMessage.aspx#422759</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/422752/422759/ReadMessage.aspx#422759"&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;declare a char array&lt;br /&gt;
char arr[420];&lt;br /&gt;
&lt;br /&gt;
input a string&lt;br /&gt;
fgets(arr, sizeof arr, stdin);&lt;br /&gt;
&lt;br /&gt;
if it's empty&lt;br /&gt;
if(arr[0] == 0)&lt;br /&gt;
&lt;br /&gt;
if it's greater than 20&lt;br /&gt;
if(strlen(arr) &amp;gt; 20)&lt;br /&gt;
&lt;br /&gt;
non-digits/spaces may take some work&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
char flag = 0,
     s[] = "123 some text 456";
int i;

for(i=0; s[i] != '\0'; ++i) {
   if(!isdigit(s[i]) &amp;amp;&amp;amp; !isspace(s[i])) {
      flag = 1; break;
   }
}

if(flag == 1) ... bad string
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
if you're limiting strings to 20 chars, the 420 max length seems like overkill. :P&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/422752/422759/ReadMessage.aspx#422759</guid>
      <pubDate>Fri, 25 Mar 2011 23:07:11 -0800</pubDate>
    </item>
    <item>
      <title>Re: need help!!!</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/422694/422709/ReadMessage.aspx#422709</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/422694/422709/ReadMessage.aspx#422709"&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;You need to use arrays here. Once you read the # of trees - you need TWO arrays: one for X coordinates and one for Y coordinates. The arrays can be allocated with malloc(), like so:&lt;/span&gt;&lt;pre class="sourcecode"&gt;
double* XTree = malloc (sizeof (double) * num_trees);
double* YTree = malloc (sizeof (double) * num_trees);
&lt;/pre&gt;&lt;span style="color: Blue;"&gt;Then you need to read all tree coordinates in a loop:&lt;/span&gt;&lt;pre class="sourcecode"&gt;
for (i=0; i&amp;lt;num_tree; i++)
{
  fscanf(fp, "%f %f", &amp;amp;x, &amp;amp;y);
  XTree [i] = x;
  YTree [i] = y;
}
&lt;/pre&gt;&lt;span style="color: Blue;"&gt;Once you did that - close the file and start your calculations. The distance between two points is calculated by following formula:&lt;/span&gt;&lt;pre class="sourcecode"&gt;
double dx = x1 - x2;
double dy = y1 - y2;
double dist = sqrt(dx*dx + dy*dy);
&lt;/pre&gt;&lt;br /&gt;
&lt;span style="color: Blue;"&gt;Then sort trees by ascending distance and pick closest tree (first one, then next ...). You also need to check the dog distance to that tree and verify that cat gets there first. If first tree fails to save the cat - try next tree until tree arrays are over. Double speed of dog means that to save cat the distance of cat to the tree must be LESS then double dog distance to the tree. Once you find that tree - cat saves himself!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/422694/422709/ReadMessage.aspx#422709</guid>
      <pubDate>Thu, 24 Mar 2011 04:51:15 -0800</pubDate>
    </item>
    <item>
      <title>Re: Own Constructor doesn't work.</title>
      <link>http://www.programmersheaven.com/mb/mfc_coding/422703/422708/ReadMessage.aspx#422708</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/mfc_coding/422703/422708/ReadMessage.aspx#422708"&gt;reply&lt;/a&gt; on the &lt;a href="http://www.programmersheaven.com/mb/mfc_coding/Board.aspx"&gt;C++ MFC&lt;/a&gt; forum.&lt;/p&gt;: Hello, &lt;br /&gt;
: &lt;br /&gt;
: I have created my own derived class which base class is CFileDialog, &lt;br /&gt;
: then I have also created my own contructor to that file, my &lt;br /&gt;
: contructor should open a file dialog box with possiblity of choosing &lt;br /&gt;
: file, but after placing a command button and clicking on it, the &lt;br /&gt;
: only thing I get is something like AfxMessageBox with error message &lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: Attempted an unsupported action &lt;br /&gt;
: &lt;br /&gt;
: I use VS C++ 2008, could you please tell me why I get this error &lt;br /&gt;
: message, please see definition of my class, below : &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: class FileDialog : public CFileDialog
: {
: 	DECLARE_DYNAMIC(FileDialog)
: 
: public:
: 
: 	// Constructor
: 	FileDialog(BOOL bOpenFileDialog,
: 	              LPCTSTR lpszFileName = NULL,
: 	              DWORD dwFlags = OFN_HIDEREADONLY | 
: OFN_OVERWRITEPROMPT,
: 	              CWnd *pParentWnd = NULL);
: 
: };
: // Contructor on button click : 
: void PageFile::OnBnClickedButton1()
: {
: 	// TODO: Add your control notification handler code here
: 	FileDialog elo(true); &lt;span style="color: Red;"&gt;//&amp;lt;-- BRKPT HERE!&lt;/span&gt;
: }
: 
: &lt;/pre&gt; &lt;br /&gt;
: &lt;br /&gt;
&lt;span style="color: Blue;"&gt;There is no code for FileDialog constructor - only declaration is here. Also, please use a debugger - put a breakpoint at constructor call (see my RED color) and press F11 to step through. You may see which exact line gives an error.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/mfc_coding/422703/422708/ReadMessage.aspx#422708</guid>
      <pubDate>Thu, 24 Mar 2011 04:33:57 -0800</pubDate>
    </item>
    <item>
      <title>Re: turbo c calculations not right</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/422625/422654/ReadMessage.aspx#422654</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/HK_MP5KPDW/"&gt;HK_MP5KPDW&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/422625/422654/ReadMessage.aspx#422654"&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;Please use code tags when posting your code samples.  Here is your program reposted with code tags provided (and formatted).&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

float workhrs, overtime, salary, tax, tsalary;
long int rate;
char name[80],choose;



try()
{
    clrscr();
    textcolor (3);
    cprintf("\n How many hours have you been working? ");
    scanf("%f",&amp;amp;workhrs);


    if(workhrs&amp;gt;=100 &amp;amp;&amp;amp; workhrs&amp;lt;=25)
    {
        printf("\nWORK HOUR is not VALID!");
        getch();
        try();
    }
    else
    {
        textcolor (3);
        printf("\n Enter your hourly rate: ");
        scanf("%d",&amp;amp;rate);
        textcolor (3);
        cprintf("\n\n\n Press any key to compute salary...");
        getch();
        if(workhrs&amp;gt;40)
        {
            if(workhrs&amp;gt;=40 &amp;amp;&amp;amp; workhrs&amp;lt;=50)
            {
                overtime=workhrs-40;
                salary=(40*rate)+(overtime*40);
            }
            else
            {
                overtime=workhrs-40;
                salary=(rate*40)+(overtime*40)+200;
            }
        }
        else
        {
            salary=workhrs*rate;
        }

        clrscr();

        if(salary&amp;gt;8000)
        {
            tax=salary*.15;
            tsalary=salary-tax;

            textcolor (15);
            cprintf("\n Hello %s! Your salary for this month is P%.2f", name, salary);
            getch();
            clrscr();
            gotoxy(1,15);
            textcolor (15);
            cprintf("\n There is a 15 percent tax deduction which is P%.2f",tax);
            getch();
            clrscr();
            gotoxy(1,15);
            printf("\n Your total salary with 15 percent tax deduction is P%.2f",tsalary);
            getch();
            clrscr();
        }
        else
        {
            printf("\n Hello %s %s! Your salary for this month is P%.2f", name, salary);
            getch();
        }

    }
}


main()
{
    clrscr();
    textcolor (3);
    printf("\n Enter name: ");
    gets(name);
    try();
    clrscr();
    gotoxy(30,45);


    printf("\nWould you like to try again? Y/N\n\n");
    scanf("%s",&amp;amp;choose);
    if (choose=='y')
        main();
    else
    {
        gotoxy(33,11);
        textcolor (15);
        cprintf("HAVE A NICE DAY!");
        getch();
    }

}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Some comments:&lt;br /&gt;
&lt;br /&gt;
1)  You are using recursion in a manner I believe to be inappropriate.  You should be using loops instead of recursion when a user enters an invalid amount of work hours or when the user wishes to repeat the program.  In particular, you should never recursively call &lt;em&gt;main&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
2)  Don't use &lt;em&gt;gets&lt;/em&gt;.  It is dangerous as it does not prevent the user from entering more characters than is possible for the array to hold.  You should instead prefer &lt;em&gt;fgets&lt;/em&gt; which allows you to specify the maximum number of characters your buffer can hold.&lt;br /&gt;
&lt;br /&gt;
3)  Avoid compiler/OS specific functions wherever possible.&lt;br /&gt;
&lt;br /&gt;
4)  Upgrade yourself to a better/newer compiler.  Turbo C was around back when most of mankind still lived in caves.  There are a number of free ones out there that have been created this millennium.&lt;br /&gt;
&lt;br /&gt;
5)&lt;br /&gt;
&lt;pre class="sourcecode"&gt;if(workhrs&amp;gt;40)
{
    if(workhrs&amp;gt;=40 &amp;amp;&amp;amp; workhrs&amp;lt;=50)
    {
        overtime=workhrs-40;
        salary=(40*rate)+(&lt;span style="color: Red;"&gt;overtime*40&lt;/span&gt;);
    }
    else
    {
        overtime=workhrs-40;
        salary=(rate*40)+(&lt;span style="color: Red;"&gt;overtime*40&lt;/span&gt;)+200;
    }
}&lt;/pre&gt;&lt;br /&gt;
Shouldn't overtime be calculated as &lt;strong&gt;overtime*rate*1.5&lt;/strong&gt; (for time-and-a-half).&lt;br /&gt;
&lt;br /&gt;
6)&lt;br /&gt;
&lt;pre class="sourcecode"&gt;else
{
    printf("\n Hello &lt;span style="color: Red;"&gt;&lt;strong&gt;%s %s&lt;/strong&gt;&lt;/span&gt;! Your salary for this month is P&lt;span style="color: Red;"&gt;&lt;strong&gt;%.2f&lt;/strong&gt;&lt;/span&gt;", &lt;span style="color: Blue;"&gt;&lt;strong&gt;name&lt;/strong&gt;&lt;/span&gt;, &lt;span style="color: Blue;"&gt;&lt;strong&gt;salary&lt;/strong&gt;&lt;/span&gt;);
    getch();
}
&lt;/pre&gt;&lt;br /&gt;
Pay attention to how many format specifiers you are using and how many additional arguments you are passing to &lt;em&gt;printf&lt;/em&gt;.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/422625/422654/ReadMessage.aspx#422654</guid>
      <pubDate>Tue, 22 Mar 2011 12:13:31 -0800</pubDate>
    </item>
    <item>
      <title>Re: turbo c calculations not right</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/422625/422641/ReadMessage.aspx#422641</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/422625/422641/ReadMessage.aspx#422641"&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;Turbo C has a very easy to use debugger - I am sure if you use it - you will see what is wrong. Set a breakpoint AFTER any input, like that:&lt;/span&gt;&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
scanf ("%f", &amp;amp;value);
&amp;lt;next line&amp;gt;           &amp;lt;-- set bkpt on this line and chk 'value'
&lt;/pre&gt;&lt;br /&gt;
&lt;span style="color: Blue;"&gt;When program stops in debugger on the next line inspect the variable 'value' and verify that whatever you entered is realy there. Do the same AFTER calculations - verify that all calculations are sound. TC debugger has WATCH window and INSPECT window - see the menu bar items - you will find how to open them. WATCH allows to see how variable changes on every line of the program - you basically watch the variable and continue step line-by-line. INSPECT - once open - must be closed to continue stepping. To put a variable into one of these windows - set a cursor on the variable and use menu item to open appropriate panel.&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/422625/422641/ReadMessage.aspx#422641</guid>
      <pubDate>Tue, 22 Mar 2011 04:00:05 -0800</pubDate>
    </item>
    <item>
      <title>Help needed.</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/422606/422606/ReadMessage.aspx#422606</link>
      <description>&lt;p&gt;&lt;a href="http://www.programmersheaven.com/user/soumenbiswas/"&gt;soumenbiswas&lt;/a&gt; posted a &lt;a href="http://www.programmersheaven.com/mb/CandCPP/422606/422606/ReadMessage.aspx#422606"&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;Dear All,&lt;br /&gt;
I am encountering one proble while compiling my existing project of VC++/MFC developped using Visual Studio 6.0 on Visual Studio 8.0 as mentioned below:&lt;br /&gt;
1&amp;gt;e:\sb\ logview.cpp(17) : error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CLogView::* )(UINT,LONG)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'&lt;br /&gt;
1&amp;gt;        None of the functions with this name in scope match the target type&lt;br /&gt;
I am also attaching the code (.cpp &amp;amp; .h) for your reference. Can you please show me where I have gone wrong and how to resolve that with code.&lt;br /&gt;
Thanking You and best regards.&lt;br /&gt;
Soumen.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/422606/422606/ReadMessage.aspx#422606</guid>
      <pubDate>Mon, 21 Mar 2011 04:14:52 -0800</pubDate>
    </item>
    <item>
      <title>Re: c</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/422563/422592/ReadMessage.aspx#422592</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/422563/422592/ReadMessage.aspx#422592"&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;are r0-r3 significant or just some marker?  I mean, do you need to process and store them too?  If not,&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
char buf[80];
int data[4] = { 0 };
FILE *fp = fopen("input.txt", "r");

if(fp) {
   while(fgets(buf, sizeof buf, fp) != NULL) {
      if((sscanf(buf, "%d %d %d %d", 
          &amp;amp;data[0], &amp;amp;data[1], &amp;amp;data[2], &amp;amp;data[3])) == 4) {
         // data[0-4] contain current line in file
      } else {
         // ints weren't converted and stored
         // r0-r3 will take this path
      }
   }
   fclose(fp);
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
"data" need not be an array; it can be four separate variables.  if later you want the floats, change the sscanf to %f instead of %d and change the ints to floats.&lt;br /&gt;
&lt;br /&gt;
oops; didn't catch values were for later use right away.  If you need to keep and store each line in the file for later use, you can do a couple of things:&lt;br /&gt;
&lt;br /&gt;
calculate and store results for each line inside of the while loop... you'd need an array or if know there's only two lines of ints, just use two variables and count the lines in the file.&lt;br /&gt;
&lt;br /&gt;
another thing you could do is use a 2D array for ints.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
int data[NUM_OF_LINES_TO_STORE][4] = { { 0 } },
    idx = 0;
while(fgets(...)) {
   if((sscanf(buf, "%d %d %d %d", 
       &amp;amp;data[idx][0], &amp;amp;data[idx][1], etc)) == 4) { 
       // increment idx on successful storing
   }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
something like that.&lt;br /&gt;
&lt;br /&gt;
HTH&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/422563/422592/ReadMessage.aspx#422592</guid>
      <pubDate>Sat, 19 Mar 2011 13:17:49 -0800</pubDate>
    </item>
    <item>
      <title>Re: c</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/422563/422589/ReadMessage.aspx#422589</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/422563/422589/ReadMessage.aspx#422589"&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;How is the input file layout?  For example, is each number on a seperate line or are all four numbers on one line?&lt;br /&gt;
&lt;br /&gt;
you can use either fscanf directly or fgets and conversion functions to store your floats.  &lt;br /&gt;
&lt;br /&gt;
do you mean convert the float to a string? if so, use sprintf&lt;br /&gt;
sprintf(char_array, "%f", float_variable);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/422563/422589/ReadMessage.aspx#422589</guid>
      <pubDate>Sat, 19 Mar 2011 11:04:06 -0800</pubDate>
    </item>
  </channel>
</rss>
