<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>C Board - C++ Programming</title>
		<link>http://cboard.cprogramming.com</link>
		<description>Questions specific to C++ Programming</description>
		<language>en</language>
		<lastBuildDate>Fri, 20 Nov 2009 22:56:29 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://cboard.cprogramming.com/images/misc/rss.jpg</url>
			<title>C Board - C++ Programming</title>
			<link>http://cboard.cprogramming.com</link>
		</image>
		<item>
			<title>simulating alt+2 (keypad) combination</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121812-simulating-altplus2-keypad-combination.html</link>
			<pubDate>Fri, 20 Nov 2009 21:02:16 GMT</pubDate>
			<description><![CDATA[I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead) 
The following doesn't seem to work. Just prints "2". 
 
 
Code: 
--------- 
keybd_event(VK_MENU,0 ,0 , 0); //Alt Press 
...]]></description>
			<content:encoded><![CDATA[<div>I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead)<br />
The following doesn't seem to work. Just prints &quot;2&quot;.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">keybd_event(VK_MENU,0 ,0 , 0); //Alt Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, 0 , 0); // 2 Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, KEYEVENTF_KEYUP,0); // 2 Release<br />
<br />
Sleep(10);<br />
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); // Alt Release<br />
<br />
Sleep(10);</code><hr />
</div>Neither does this work. Just prints &quot;2&quot;, again.<br />
<br />
	<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">INPUT inputs = {0}; <br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.type = INPUT_KEYBOARD; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; KEYBDINPUT ki = {0}; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_LMENU;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_NUMPAD2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.dwFlags = KEYEVENTF_KEYUP;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_NUMPAD2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_LMENU;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>kangekraam</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121812-simulating-altplus2-keypad-combination.html</guid>
		</item>
		<item>
			<title>Arrays and Functions</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121807-arrays-functions.html</link>
			<pubDate>Fri, 20 Nov 2009 20:02:57 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I have created a simple program that will be adding data into a file, but I need to get this part going first. I'm having a problem when trying to add the name of the item. It skips that line and jumps to the next one not letting me to enter the name. Any help on this will be appreciated....]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I have created a simple program that will be adding data into a file, but I need to get this part going first. I'm having a problem when trying to add the name of the item. It skips that line and jumps to the next one not letting me to enter the name. Any help on this will be appreciated.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;cctype&gt;<br />
<br />
#define cMax 100<br />
<br />
using namespace std;<br />
<br />
void invMenu();<br />
void crtNewItem(double Qty[], double iPrice[], char iName[], int pNumber[]);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; int mSelec;<br />
&nbsp; &nbsp; bool bDone = false;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; do{<br />
<br />
cout &lt;&lt; &quot;1. Inventory Management&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;\nPlease enter your selection [1-5]&quot; &lt;&lt; endl;<br />
cin &gt;&gt; mSelec;<br />
while (mSelec &lt; 1&nbsp; || mSelec &gt; 5)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter a correct selection between 1-5&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; mSelec;<br />
}<br />
<br />
switch(mSelec)<br />
{<br />
&nbsp; case 1: invMenu();<br />
&nbsp; break;<br />
<br />
&nbsp;  }<br />
}while (!bDone);<br />
return 0;<br />
<br />
}<br />
<br />
void invMenu()<br />
<br />
&nbsp;{<br />
&nbsp; &nbsp; double Qty[cMax];<br />
&nbsp; &nbsp; double iPrice[cMax];<br />
&nbsp; &nbsp; char iName[cMax];<br />
&nbsp; &nbsp; int pNumber[cMax];<br />
<br />
&nbsp; &nbsp; int iSelec = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;cls&quot;);<br />
<br />
cout &lt;&lt; &quot;\n1. Create New Item&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;\nPlease enter your selection [1-6]&quot; &lt;&lt; endl;<br />
cin &gt;&gt; iSelec;<br />
while (iSelec &lt; 1&nbsp; || iSelec &gt; 6)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter a correct selection. [1-6]&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; iSelec;<br />
}<br />
<br />
switch(iSelec)<br />
{<br />
&nbsp; &nbsp; case 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //This calls out the fuction to create a new item.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; crtNewItem(Qty,iPrice,iName,pNumber);<br />
&nbsp; &nbsp; break;<br />
}<br />
<br />
&nbsp;}<br />
<br />
void crtNewItem(double Qty[], double iPrice[], char iName[], int pNumber[])<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;cls&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ofstream outputFile;<br />
<br />
&nbsp;outputFile.open(&quot;InvItems.txt&quot;, ios::app);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the quantity of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; Qty[cMax];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the name of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin.getline(iName, cMax);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the part number of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; pNumber[cMax];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the price of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; iPrice[cMax];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputFile &lt;&lt; Qty[cMax] &lt;&lt; setw(10) &lt;&lt; iName[cMax] &lt;&lt; setw(10) &lt;&lt; pNumber[cMax] &lt;&lt; setw(10) &lt;&lt; iPrice[cMax] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputFile.close();<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n************************************************&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\nYou have just added a new item to the inventory!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n************************************************&quot; &lt;&lt; endl &lt;&lt; endl;<br />
}</code><hr />
</div>Any advice on how to solve this will be appreciated. Thanks!</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>drkidd22</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121807-arrays-functions.html</guid>
		</item>
		<item>
			<title>CPU increase with precomputed tables?</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121806-cpu-increase-precomputed-tables.html</link>
			<pubDate>Fri, 20 Nov 2009 19:44:58 GMT</pubDate>
			<description><![CDATA[(edit: I'm done editing now, I promise. Maybe.) 
 
The problem is that using precomputed tables results in higher CPU usage and that's confusing me. The routine which creates the table is in fact occurring outside of the applications render loop. It is NOT being recomputed every iteration. 
 
So...]]></description>
			<content:encoded><![CDATA[<div>(edit: I'm done editing now, I promise. Maybe.)<br />
<br />
The problem is that using precomputed tables results in higher CPU usage and that's confusing me. The routine which creates the table is in fact occurring outside of the applications render loop. It is NOT being recomputed every iteration.<br />
<br />
So here are the details;<br />
<br />
I've designed a class which executes some numerical algorithms and I've added some methods which allow user to specify the location to some precomputed tables to speed things up.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">vector&lt; vector&lt; float &gt; &gt; *TCOS, *TSIN;<br />
//...<br />
void ALG::UseTrigTables(vector&lt; vector&lt; float &gt; &gt; *fsin, vector&lt; vector&lt; float &gt; &gt; *fcos)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; TCOS = fcos;<br />
&nbsp; &nbsp; &nbsp; &nbsp; TSIN = fsin;<br />
}</code><hr />
</div>After the object is created I will attach the tables like so;<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">vector&lt; vector&lt; float &gt; &gt;<br />
&nbsp;tcos(N, vector&lt; float &gt; (N)),<br />
&nbsp;tsin(N, vector&lt; float &gt; (N));<br />
<br />
// [insert loop here to fill vector-vectors with data]... etc...<br />
<br />
Blah.UseTrigTables(&amp;fsin, &amp;fcos)</code><hr />
</div>Within the class the tables are used like so;<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">float f0;<br />
for (int k = 0; k &lt; N; ++k)<br />
for (int j = 0; j &lt; N; ++j)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; f0 = fA[k] * fB[j] * (*TSIN)[k][j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; // ...<br />
}</code><hr />
</div>Why would that increase CPU usage?<br />
<br />
With trig: ~8%<br />
With tables: ~10%<br />
<br />
Where N = 128  (size of tables/loop)<br />
<br />
My first guess;<br />
<br />
While I am passing a pointer, maybe I'm missing something critical and the tables are actually being copied to a new location in memory every time i call them??<br />
<br />
If not, what exact tools do you recommend I use to profile this applications behavior?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>since</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121806-cpu-increase-precomputed-tables.html</guid>
		</item>
		<item>
			<title>Basic operator overloading question</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121802-basic-operator-overloading-question.html</link>
			<pubDate>Fri, 20 Nov 2009 18:04:22 GMT</pubDate>
			<description><![CDATA[Hi there, 
 
I'm just starting to try out Operator Overloading and wrote a basic definition for the equality operator ==. 
 
*base.h :* 
 
Code: 
--------- 
class Base 
{]]></description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
I'm just starting to try out Operator Overloading and wrote a basic definition for the equality operator ==.<br />
<br />
<b>base.h :</b><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">class Base<br />
{<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Base (int a);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int getNo() const { return m_a; }<br />
<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; int m_a;<br />
};<br />
Base::Base(int a)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; m_a = a;<br />
<br />
}<br />
bool operator==(const Base&amp; leftparameter, const&nbsp; Base&amp; rightparameter)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; leftparameter.getNo() == rightparameter.getNo();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return true;<br />
}</code><hr />
</div><b><br />
main.cpp :</b><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;iostream&gt;<br />
#include &quot;base.h&quot;<br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Base obj1(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Base obj2(1);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(obj1 == obj2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Objects match&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Objects don't match&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; system (&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</code><hr />
</div>Just a basic query, Visual Studio reports:<br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="1" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				warning C4553: '==' : operator has no effect; did you intend '='?
			
			<hr />
		</td>
	</tr>
	</table>
</div>I'm just wondering why it says == has no effect when it does successfully compare the two objects. <br />
I don't see why would it think I meant to assign one object to another.<br />
<br />
Should I not worry about it? Or am I missing the point of the warning?<br />
<br />
Thanks for any info!</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>Swerve</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121802-basic-operator-overloading-question.html</guid>
		</item>
		<item>
			<title>Bracket Checker</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121792-bracket-checker.html</link>
			<pubDate>Fri, 20 Nov 2009 10:06:20 GMT</pubDate>
			<description>i dont want anybody to solve this problem for me ,, i jus want you guys to help me understanding the problem,, i didnt really get which sequence is valid or not,,How should i start solving the problem etc,,any hints regarding member functions n data members!! 
 
 
 
Correct Sequence of brackets is...</description>
			<content:encoded><![CDATA[<div>i dont want anybody to solve this problem for me ,, i jus want you guys to help me understanding the problem,, i didnt really get which sequence is valid or not,,How should i start solving the problem etc,,any hints regarding member functions n data members!!<br />
<br />
<br />
<br />
Correct Sequence of brackets is always of primary importance both for written programs and mathematical expressions. By correct sequence we mean that for every opening bracket there is a closing bracket. The problem is to write a program that takes a random sized (size max 15) input of brackets from user, as a string, and can validate the sequence for e.g. <br />
{([]{()})}   valid<br />
{[]}(} 	invalid<br />
[]{{{} 	invalid<br />
(((})))	invalid<br />
{{{}}}}	invalid<br />
Reminder:<br />
•	Use stack to solve the problem.<br />
•	Use Stack class in some other class that uses stack to validate the sequence.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>Fatima Rizwan</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121792-bracket-checker.html</guid>
		</item>
		<item>
			<title>Question on overloading the operator delete...</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121791-question-overloading-operator-delete.html</link>
			<pubDate>Fri, 20 Nov 2009 07:06:21 GMT</pubDate>
			<description><![CDATA[I'm curious to know how i would get around the static member error.  
 
 
Code: 
--------- 
 
#include <stdlib.h> 
 
 
struct image]]></description>
			<content:encoded><![CDATA[<div>I'm curious to know how i would get around the static member error. <br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
#include &lt;stdlib.h&gt;<br />
<br />
<br />
struct image<br />
{&nbsp; &nbsp;  short count;<br />
&nbsp; &nbsp; &nbsp; unsigned int * num;<br />
&nbsp; &nbsp; &nbsp; unsigned int ** nums;<br />
&nbsp; &nbsp; &nbsp; void Init( short number )<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num&nbsp; = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nums = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count = number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( number == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num = (unsigned int *)malloc( sizeof(unsigned int));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if ( number &gt; 1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nums = (unsigned int **)malloc( sizeof(unsigned int) * number);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( i = 0; i &lt; count; ++i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nums[count] = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void operator delete (void *p)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image * q = (image * )p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if( q-&gt;count == 1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  { free(q-&gt;num); num = NULL ; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if( q-&gt;count &gt; 1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( i = 0; i &lt; q-&gt;count; ++i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if( q-&gt;nums[q-&gt;count] != NULL )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  free( q-&gt;nums[q-&gt;count] );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; free( q-&gt;nums );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  free(p);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  p = NULL;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; <br />
};<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; int main(void)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image * something;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; something-&gt;Init( 1 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delete something;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; }</code><hr />
</div>I was trying to make a image struct to hold either 1 array of unsigned integers or an array of images. I wanted to push each structure into a class hash table I built a while back, but I had an issue using delete in my hash table and with the lost of memory from the array of unsigned int. So i thought about using a overloaded method for delete to avoid the problem, and not to reconstruct my hash table just around this one issue.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>Darkinyuasha1</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121791-question-overloading-operator-delete.html</guid>
		</item>
		<item>
			<title>if statements in c++ compared to java</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121787-if-statements-cplusplus-compared-java.html</link>
			<pubDate>Fri, 20 Nov 2009 03:39:09 GMT</pubDate>
			<description><![CDATA[In java i believe that the 'condition' of an if statement must evaluate to a boolean, is this true as well for c++?]]></description>
			<content:encoded><![CDATA[<div>In java i believe that the 'condition' of an if statement must evaluate to a boolean, is this true as well for c++?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>rodrigorules</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121787-if-statements-cplusplus-compared-java.html</guid>
		</item>
		<item>
			<title>friend function template class declaration error</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121785-friend-function-template-class-declaration-error.html</link>
			<pubDate>Fri, 20 Nov 2009 02:37:19 GMT</pubDate>
			<description><![CDATA[this:  
 
 
Code: 
--------- 
friend vector<type, n> (::operator/<>)(const type div, const vector<type, n>& v); 
--------- 
generates this error: 
 
vector.h:45: error: expected `)' before â<â token]]></description>
			<content:encoded><![CDATA[<div>this: <br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">friend vector&lt;type, n&gt; (::operator/&lt;&gt;)(const type div, const vector&lt;type, n&gt;&amp; v);</code><hr />
</div>generates this error:<br />
<br />
vector.h:45: error: expected `)' before â&lt;â token<br />
<br />
why is that?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>-EquinoX-</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121785-friend-function-template-class-declaration-error.html</guid>
		</item>
		<item>
			<title>Binary tree wont go left!!!</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121782-binary-tree-wont-go-left.html</link>
			<pubDate>Thu, 19 Nov 2009 23:29:48 GMT</pubDate>
			<description>Hello, 
I am new to programming and cant figure out this problem. The program works fine if i use int numbers but breaks when i change to names of type string. 
the total code is at 
C++ pastebin - collaborative debugging tool (http://pastebin.com/m59ae03d0) 
but the place i am stuck at is 
 
Code:...</description>
			<content:encoded><![CDATA[<div>Hello,<br />
I am new to programming and cant figure out this problem. The program works fine if i use int numbers but breaks when i change to names of type string.<br />
the total code is at<br />
<a href="http://pastebin.com/m59ae03d0" target="_blank">C++ pastebin - collaborative debugging tool</a><br />
but the place i am stuck at is<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">void addNode(string name, int weight)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treeNode *newNode = new treeNode(name, weight);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (root == 0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; root = newNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treeNode *temp = root;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (temp-&gt;left != 0 &amp;&amp; temp-&gt;name &lt;= name)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (temp-&gt;left == 0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;left = newNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // move to subtree<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = temp-&gt;left;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (name &lt; temp-&gt;name)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (temp-&gt;right == 0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp-&gt;right = newNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // move to subtree<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = temp-&gt;right;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(name &gt; temp-&gt;name)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = temp-&gt;right;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //else if (name == temp-&gt;name)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>the code always goes to the right when I debug.<br />
any insight would be wonderfull<br />
thanks</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>datastructs</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121782-binary-tree-wont-go-left.html</guid>
		</item>
		<item>
			<title>Help with quicksort</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121779-help-quicksort.html</link>
			<pubDate>Thu, 19 Nov 2009 20:15:58 GMT</pubDate>
			<description><![CDATA[I need help implementing quick sort on this but everything else works right. I don't get any errors when compiling the program but when I run it and enter the values I get an error that says it has stopped working. Thanks for any help in advance. 
 
Code: 
--------- 
#include <iostream> 
#include...]]></description>
			<content:encoded><![CDATA[<div>I need help implementing quick sort on this but everything else works right. I don't get any errors when compiling the program but when I run it and enter the values I get an error that says it has stopped working. Thanks for any help in advance.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
using namespace std;<br />
<br />
const int MAX_ACCOUNTS = 200;<br />
<br />
void readcustomeridacctbalance(int idarray[], int numaccounts, double balancearray[]);<br />
void quicksort(int idarr[], int low, int high);<br />
void displaydata(int idarray[], int numaccounts, double balancearray[], double minpayment[]);<br />
<br />
void main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int number,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idarray[MAX_ACCOUNTS];<br />
&nbsp; &nbsp; &nbsp; &nbsp; double balancearray[MAX_ACCOUNTS],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  minreqpayment[MAX_ACCOUNTS];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter the number of accounts: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(number&gt;MAX_ACCOUNTS)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;That is an invalid number of accounts. Please reenter: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; readcustomeridacctbalance(idarray, number, balancearray);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int left = idarray[0],<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; right = idarray[number];<br />
&nbsp; &nbsp; &nbsp; &nbsp; quicksort(idarray, left, right);<br />
&nbsp; &nbsp; &nbsp; &nbsp; displaydata(idarray, number, balancearray, minreqpayment);<br />
}<br />
<br />
void readcustomeridacctbalance(int idarray[], int numaccounts, double balancearray[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; numaccounts; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;What is your ID number? &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; idarray[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;What is your account balance? &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; balancearray[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
void quicksort(int idarr[], int low, int high)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; i = low,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = high,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmp,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pivot = idarr[(low+high)/2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (i &lt;= j)&nbsp; &nbsp; &nbsp; &nbsp; //While there is more than 1 account<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (idarr[i] &lt; pivot)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (idarr[j] &gt; pivot)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j--;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i &lt;= j) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmp = idarr[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idarr[i] = idarr[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idarr[j] = tmp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j--;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; };<br />
&nbsp; &nbsp; &nbsp; // recursion<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (low &lt; j)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; quicksort(idarr, low, j);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (i &lt; high)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; quicksort(idarr, i, high);<br />
}<br />
<br />
void displaydata(int idarray[], int numaccounts, double balancearray[], double minpayment[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; unsigned int totalid=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double totalbalance=0,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  totalminpayment=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;_______________________________________________________________\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;setw(11)&lt;&lt;&quot;ID&quot;&lt;&lt;setw(20)&lt;&lt;&quot;Account Balance\n&quot;&lt;&lt;setw(31)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;_______________________________________________________________\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; numaccounts; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;setw(11)&lt;&lt;idarray[i]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;setw(10)&lt;&lt; &quot;$&quot; &lt;&lt; balancearray[i]&lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalid+=idarray[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalbalance+=balancearray[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;_______________________________________________________________\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Total: &quot; &lt;&lt; setw(1) &lt;&lt; totalid &lt;&lt; setw(10) &lt;&lt; &quot;$&quot; &lt;&lt; totalbalance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw(27)&lt;&lt; &quot;\n\nAverage Account Balance: $&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; totalbalance/numaccounts &lt;&lt; &quot;\n&quot;;<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>c++prog</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121779-help-quicksort.html</guid>
		</item>
		<item>
			<title>Concatinate strings located inside a vector.</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121777-concatinate-strings-located-inside-vector.html</link>
			<pubDate>Thu, 19 Nov 2009 18:26:30 GMT</pubDate>
			<description><![CDATA[Hi guys, first off i'm trying to Write a program that reads a series of strings into a vector and then prints out a string with all elements concatenated, with each element separated with a "-". So if the input is "hello world" then your proram should output "hello-world". 
 
 
 This program...]]></description>
			<content:encoded><![CDATA[<div>Hi guys, first off i'm trying to Write a program that reads a series of strings into a vector and then prints out a string with all elements concatenated, with each element separated with a &quot;-&quot;. So if the input is &quot;hello world&quot; then your proram should output &quot;hello-world&quot;.<br />
<br />
<br />
 This program doesn't seem too hard at first glance and below is my current progress. I'm only on chapter 3 of my book so this program shouldnt be overly complicated. What is getting me confused it the book does a poor job explaining how to treat and munipulate the data inside the vector. Once the series of strings is loaded into the vector can we still treat the data as if they were strings.<br />
<br />
My thought process behind this would be the same way as I would replace printable whitespace with a &quot;-&quot; character by going through the data located within the string one char at a time but that doesn't seem to be working.<br />
<br />
I guess my real question is what is the best way to treat the strings located inside the vector. Any help or suggestions is greatly appreciated.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;cctype&gt;<br />
#include &lt;vector&gt;<br />
<br />
using std::cin ;<br />
using std::cout;<br />
using std::string;<br />
using std::vector;<br />
<br />
int main(){<br />
<br />
&nbsp; vector&lt;string&gt; text() ;&nbsp; //empty vector<br />
<br />
&nbsp; cout &lt;&lt; &quot;Please enter a string&quot; ;<br />
<br />
&nbsp; while( cin &gt;&gt; text){&nbsp; &nbsp; //append word to text<br />
&nbsp; &nbsp; text.push_back(word);<br />
<br />
// This is the part thats throwing me for loop&nbsp; below (no pun intended)<br />
<br />
&nbsp; for( vector&lt;string&gt; :: size_type index = 0 ; index != text.size(); ++index)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; if ( isspace(text[index])){<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;-&quot; ;<br />
<br />
&nbsp; &nbsp; &nbsp; }else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; text[index] ;<br />
&nbsp; &nbsp; &nbsp; }}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>sniperwire</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121777-concatinate-strings-located-inside-vector.html</guid>
		</item>
		<item>
			<title>Simplest way to calculate the string content?</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121772-simplest-way-calculate-string-content.html</link>
			<pubDate>Thu, 19 Nov 2009 14:35:17 GMT</pubDate>
			<description><![CDATA[Hi 
 
What is the simplest way to calculate string like: 
 
String^ numbers = "15+3*2"; 
 
 
In php I used eval(), but I can't find a function like eval() in c++. 
 
Thx!]]></description>
			<content:encoded><![CDATA[<div>Hi<br />
<br />
What is the simplest way to calculate string like:<br />
<br />
String^ numbers = &quot;15+3*2&quot;;<br />
<br />
<br />
In php I used eval(), but I can't find a function like eval() in c++.<br />
<br />
Thx!</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>pvujic</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121772-simplest-way-calculate-string-content.html</guid>
		</item>
		<item>
			<title>Save function not working</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121771-save-function-not-working.html</link>
			<pubDate>Thu, 19 Nov 2009 14:24:15 GMT</pubDate>
			<description>Is this legal becuase it does not work, the file is created according to the argument passed into the function ok but after closing it is blank, if i do it without the if statements it works fine. 
 
 
Code: 
--------- 
void SolBoard::SaveGame(int myfile)     
{ 
    ofstream Gamefile; 
 
   ...</description>
			<content:encoded><![CDATA[<div>Is this legal becuase it does not work, the file is created according to the argument passed into the function ok but after closing it is blank, if i do it without the if statements it works fine.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">void SolBoard::SaveGame(int myfile)&nbsp; &nbsp; <br />
{<br />
&nbsp; &nbsp; ofstream Gamefile;<br />
<br />
&nbsp; &nbsp; if(myfile == 0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //which file to write over.<br />
&nbsp; &nbsp; ofstream Gamefile(&quot;mysave0.txt&quot;);<br />
&nbsp; &nbsp; if(myfile == 1)<br />
&nbsp; &nbsp; ofstream Gamefile(&quot;mysave1.txt&quot;);<br />
&nbsp; &nbsp; if(myfile == 2)<br />
&nbsp; &nbsp; ofstream Gamefile(&quot;mysave2.txt&quot;);<br />
<br />
&nbsp; &nbsp; for(countclick = 0; countclick &lt; 49; countclick++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; Gamefile &lt;&lt; moves_record[moves][countclick];<br />
&nbsp; &nbsp; &nbsp; &nbsp; Gamefile&lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; Gamefile.close();<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>rogster001</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121771-save-function-not-working.html</guid>
		</item>
		<item>
			<title>unary plus</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121768-unary-plus.html</link>
			<pubDate>Thu, 19 Nov 2009 13:45:47 GMT</pubDate>
			<description><![CDATA[I have rewritten bjarne stroustrup's calculator program to accept input from a file and parse it and evaluate it. Everything works fine except for the instance where the plus sign acts as a signed value. For example 3*+2.5 equals 7.5 but the program expects a parenthesis. How can I implement the...]]></description>
			<content:encoded><![CDATA[<div>I have rewritten bjarne stroustrup's calculator program to accept input from a file and parse it and evaluate it. Everything works fine except for the instance where the plus sign acts as a signed value. For example 3*+2.5 equals 7.5 but the program expects a parenthesis. How can I implement the change?<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case MINUS :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // unary minus<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return -prim(true);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case LP :<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double e = expr(true);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (curr_tok != RP) return error(&quot;')' expected&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get_token();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //eat ')'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return e;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</code><hr />
</div>This is what is applied when a unary minus is used but I cannot add a unary plus statement since it creates an error that plus is already used.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>cengineer</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121768-unary-plus.html</guid>
		</item>
		<item>
			<title>Problem with command line arguments</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121764-problem-command-line-arguments.html</link>
			<pubDate>Thu, 19 Nov 2009 11:44:29 GMT</pubDate>
			<description><![CDATA[Hi all, 
 
I was reading Lesson 14: Accepting command line argements. There was a sample program. I manage to compile it but when executed, this message appeared: 
 
usage: D:\CommandArg\Debug\CommandArg.exe <filename> 
Press any key to continue 
 
The thing is, i wasn't even able to enter any file...]]></description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I was reading Lesson 14: Accepting command line argements. There was a sample program. I manage to compile it but when executed, this message appeared:<br />
<br />
usage: D:\CommandArg\Debug\CommandArg.exe &lt;filename&gt;<br />
Press any key to continue<br />
<br />
The thing is, i wasn't even able to enter any file name. Upon clicking the execute program button, this message appears right away. Can someone help me with this? I am using Visual C++ 6. Thank you.<br />
<br />
The code from lesson 14 is as follows:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><br />
#include &lt;fstream&gt;<br />
#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
int main ( int argc, char *argv[] )<br />
{<br />
&nbsp; if ( argc != 2 ) // argc should be 2 for correct execution<br />
&nbsp; &nbsp; // We print argv[0] assuming it is the program name<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;usage: &quot;&lt;&lt; argv[0] &lt;&lt;&quot; &lt;filename&gt;\n&quot;;<br />
&nbsp; else {<br />
&nbsp; &nbsp; // We assume argv[1] is a filename to open<br />
&nbsp; &nbsp; ifstream the_file ( argv[1] );<br />
&nbsp; &nbsp; // Always check to see if file opening succeeded<br />
&nbsp; &nbsp; if ( !the_file.is_open() )<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Could not open file\n&quot;;<br />
&nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; char x;<br />
&nbsp; &nbsp; &nbsp; // the_file.get ( x ) returns false if the end of the file<br />
&nbsp; &nbsp; &nbsp; //&nbsp; is reached or an error occurs<br />
&nbsp; &nbsp; &nbsp; while ( the_file.get ( x ) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; x;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; // the_file is closed implicitly here<br />
&nbsp; }<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>elmvin_s</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121764-problem-command-line-arguments.html</guid>
		</item>
	</channel>
</rss>
