<?xml version="1.0" encoding="utf-8"?>

<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>DaniWeb IT Discussion Community - C++</title>
		<link>http://www.daniweb.com/forums/</link>
		<description><![CDATA[Our C++ forum is the place for Q&A-style discussions related to this popular language.  Note we have a separate C forum for non-OOP straight C. Please direct C++ questions directly related to game development to our Game Development forum.]]></description>
		<language>en-US</language>
		<lastBuildDate>Sat, 21 Nov 2009 21:22:31 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/alphaimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - C++</title>
			<link>http://www.daniweb.com/forums/</link>
		</image>
		<item>
			<title>Need this program done by tonight. Any help would be great.</title>
			<link>http://www.daniweb.com/forums/thread240310.html</link>
			<pubDate>Sat, 21 Nov 2009 20:59:26 GMT</pubDate>
			<description><![CDATA[So I am programming a heap sort and i am gettin pretty close to where i need to be, but I am having trouble in one of my functions when it heapifies my array. here is the code. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>So I am programming a heap sort and i am gettin pretty close to where i need to be, but I am having trouble in one of my functions when it heapifies my array. here is the code.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream&gt;<br />
using namespace std;<br />
&nbsp; &nbsp; <br />
class Heapsort<br />
{<br />
&nbsp; private:<br />
&nbsp; &nbsp;  int *array;<br />
&nbsp; &nbsp;  int mysize;<br />
&nbsp; public:<br />
&nbsp; &nbsp;  Heapsort(int);<br />
&nbsp; &nbsp;  ~Heapsort();<br />
&nbsp; &nbsp;  bool empty();<br />
&nbsp; &nbsp;  int percolate_down(int);<br />
&nbsp; &nbsp;  void heapify();<br />
&nbsp; &nbsp;  void fill_array();<br />
&nbsp; &nbsp;  void print();<br />
};<br />
&nbsp; &nbsp; <br />
Heapsort::Heapsort(int a)<br />
{<br />
&nbsp;  mysize = a;<br />
&nbsp;  int *array = new int[mysize];<br />
}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
Heapsort::~Heapsort()<br />
{<br />
&nbsp;  delete [] array;<br />
}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
void Heapsort::fill_array()<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; for (i = 1; i &lt; mysize; i++){<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\nEnter a number: &quot;;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; array[i];<br />
&nbsp; &nbsp; }<br />
&nbsp;<br />
&nbsp; &nbsp; print();&nbsp; &nbsp; //This is here to check for the error im getting.<br />
}<br />
&nbsp;<br />
int Heapsort::percolate_down(int r)<br />
{&nbsp; <br />
&nbsp; &nbsp; int t=0;<br />
&nbsp; &nbsp; int c = 2*r;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; while (r &lt; mysize){<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((c &lt; mysize) &amp;&amp; (array[c] &lt; array[c+1])){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (array[r] &lt; array[c]){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = array[c];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array[c] = array[r];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array[r] = t;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r=c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c=2*c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print();&nbsp; //Again, checking the error, the print out shows that<br />
&nbsp; &nbsp; &nbsp; &nbsp; }else{&nbsp; &nbsp; //the data somehow changes in the middle of loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }&nbsp; <br />
&nbsp; &nbsp; return (r);<br />
}<br />
<br />
void Heapsort::heapify()<br />
{&nbsp; <br />
&nbsp;  int r = mysize/2;&nbsp;  <br />
&nbsp;  <br />
&nbsp;  for(r; r &gt; 0; r--){<br />
&nbsp; &nbsp; &nbsp; percolate_down(r);<br />
&nbsp;  }&nbsp; &nbsp; <br />
&nbsp;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
void Heapsort::print()<br />
{ <br />
&nbsp; int j;<br />
&nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; for (j=1; j &lt; mysize; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; array[j] &lt;&lt; &quot;&nbsp; &quot;;<br />
}<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
int main()<br />
{<br />
&nbsp; Heapsort heap(7);<br />
&nbsp; <br />
&nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; <br />
&nbsp; heap.fill_array();<br />
&nbsp;<br />
&nbsp; heap.heapify();<br />
<br />
&nbsp; heap.print();<br />
&nbsp;  <br />
&nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp;  <br />
&nbsp; return (0);<br />
}</pre><br />
And this is the out put i am getting.<br />
<br />
AFTER I INPUT THE INTEGERS INTO ARRAY:<br />
1   2    3    4    5    6<br />
<br />
DURING MY WHILE LOOP IN PERCOLATE_DOWN():<br />
1  2  6  4  5  3  <br />
<br />
1  5  6  4  2  3  <br />
<br />
1  5  6  4  671410272  3  <br />
<br />
6  5  1  4  671410272  3  <br />
<br />
6  5  3  4  671410272  1  <br />
<br />
6  5  3  4  671410272  1  <br />
<br />
<br />
<br />
<br />
I have no idea why in the middle of the loop, the data point just changes.<br />
<br />
p.s. I havnt gotten to the sorting part, this is just up to put the data into a heap.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bigmaq</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240310.html</guid>
		</item>
		<item>
			<title><![CDATA[[VC++ 6] Debugging ASM Code?]]></title>
			<link>http://www.daniweb.com/forums/thread240303.html</link>
			<pubDate>Sat, 21 Nov 2009 19:48:08 GMT</pubDate>
			<description>Hi, I heard that I can see how VC++ 6.0 converts my C++ code to assembly so I can rewrite it in assembly while removing useless junk.  Could somebody tell me how this would be done? 
 
Well, guess ill just use ollydbg to see how my programs converted</description>
			<content:encoded><![CDATA[<div>Hi, I heard that I can see how VC++ 6.0 converts my C++ code to assembly so I can rewrite it in assembly while removing useless junk.  Could somebody tell me how this would be done?<br />
<br />
Well, guess ill just use ollydbg to see how my programs converted</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>scriptkiddy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240303.html</guid>
		</item>
		<item>
			<title><![CDATA[The do-while that doesn't]]></title>
			<link>http://www.daniweb.com/forums/thread240298.html</link>
			<pubDate>Sat, 21 Nov 2009 19:31:42 GMT</pubDate>
			<description><![CDATA[Everything below works the first time through, and the validation of the user's choice to proceed or not works, as does his choice to quit; but when it gets to cin.getline it just blows right through it without waiting for input.  As my parents used to say, Where have I gone wrong? 
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Everything below works the first time through, and the validation of the user's choice to proceed or not works, as does his choice to quit; but when it gets to cin.getline it just blows right through it without waiting for input.  As my parents used to say, Where have I gone wrong?<br />
<br />
 <pre style="margin:20px; line-height:13px">//CIS 180 Rich Mansfield 0457321 11/20/09<br />
//This program checks to see if an input is a palindrome<br />
<br />
#include&lt;cstdio&gt;<br />
#include&lt;cstdlib&gt;<br />
#include&lt;iostream&gt;<br />
#include&lt;string&gt;<br />
#include&lt;cctype&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int MAX = 81;//Array size; no magic numbers; last char is null terminator<br />
&nbsp; &nbsp; &nbsp; &nbsp; char str[MAX];//Array to hold raw user input<br />
&nbsp; &nbsp; &nbsp; &nbsp; char proceed;//To allow user to choose to proceed or not, after initial run<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; do //one time initially; user gets to choose to repeat or not at end<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // Get a line of input.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Input a string of no more than &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; (MAX - 1) &lt;&lt; &quot; characters:\n&quot;;//saves last space for null terminator<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cin.getline(str, MAX);//getline allows white space chars<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //Doesn't pick up getline on second iteration<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // Display the input one character at a time.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int count = 0;// Loop counter variable<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;The sentence you entered is:\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  while (str[count] != '\0')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; str[count];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; &nbsp; &nbsp; &nbsp; //End while going through string<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int strlength;//var used to find pairs of characters to compare<br />
&nbsp; &nbsp; &nbsp; &nbsp; strlength = strlen(str);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Convert all the characters in the string str to uppercase<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; MAX; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(str[i])//if there IS a character at that location<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str[i] = toupper(str[i]);//make sure it's uppercase (if already upper, no change)<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; str&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Remove all the special characters except letters a - z<br />
&nbsp; &nbsp; &nbsp; &nbsp; char str2[MAX];//Will need a new string to hold just the alpha dogs<br />
&nbsp; &nbsp; &nbsp; &nbsp; int j=0;//and a counter for its elements<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //str2 is declared to max out at 81, but I don't have to look at all of it<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; strlength; i++)//strlength is all I need to look at<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isalpha(str[i]))//if the next character is a letter,<br />
&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; str2[j] = str[i];//pass it into the new string<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j++;//increment j to go to next element in new string<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;  //End of if isalpha<br />
&nbsp; &nbsp; &nbsp; &nbsp; str2[j]= '\0';//Put null terminator at end of new string<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; str2&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&nbsp; &nbsp; &nbsp; &nbsp; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;strlength is &quot;&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; strlength&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;j is &quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; j<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; back = j - 1;//back index points to the last character, drops the \0<br />
&nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; flag = 1;//start with true value for flag; set to break if it goes false<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Compare the first character with the last character.<br />
&nbsp; &nbsp; &nbsp; &nbsp; //If they're are the same, compare the next characters.<br />
&nbsp; &nbsp; &nbsp; &nbsp; //front index is pointed to the first character in the string str2<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int front = 0; front &lt;= j/2 ; front++)//j is the position of the \0 in str2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //so j/2 is the midpoint that both back and front are converging on;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //as long as front &lt; j/2, it keeps incrementing.<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(str2[front] != str2[back - front])//comparing first element (0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //to last element (j - 1, or back, is last element, not counting \0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //subtracting front el doesn't change that, at first, because 1st position is 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //but from then on, back decrements as fast as front increments<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; //End if string pairs not equal<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; //End for loop comparing all pairs of characters<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(flag == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;It is not a palindrome&quot;&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;It's a palindrome&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Re-initialize basic array in case user wants to do it again<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Nope; doesn't work whether I have the next two lines, or not<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int MAX = 81;//Array size; no magic numbers; last char is null terminator<br />
&nbsp; &nbsp; &nbsp; &nbsp; char str[MAX];//Array to hold raw user input<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Does the user want to do it again? pg495<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;One more time? (y/n) &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; proceed;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Validate response<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (tolower (proceed) != 'y' &amp;&amp; tolower(proceed) != 'n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Please enter y or n: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&nbsp; &nbsp; &nbsp; &nbsp; &gt;&gt; proceed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; while (tolower(proceed) == 'y');//End do while<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; //End main fn</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>richman0829</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240298.html</guid>
		</item>
		<item>
			<title>Overloaded function</title>
			<link>http://www.daniweb.com/forums/thread240297.html</link>
			<pubDate>Sat, 21 Nov 2009 19:24:01 GMT</pubDate>
			<description>I am trying to code the below program using overloaded function which give me output is the answer in correct or not for the three different question, the answers are already provided in the program all I have to check the answer and give the output statement if the answer is correct or incorrect,...</description>
			<content:encoded><![CDATA[<div>I am trying to code the below program using overloaded function which give me output is the answer in correct or not for the three different question, the answers are already provided in the program all I have to check the answer and give the output statement if the answer is correct or incorrect, I am able to run the below mentioned code but the output is weired, please look at it and help me with this.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
void checkQuestion(int, string, bool);<br />
<br />
int main(int argc, char *argv[])<br />
{<br />
&nbsp; &nbsp; int intAnswer = 3;<br />
&nbsp; &nbsp; string stringAnswer = &quot;Abraham Lincoln&quot;;<br />
&nbsp; &nbsp; bool boolAnswer = true;<br />
&nbsp; &nbsp; string result[]={&quot;correct&quot;, &quot;incorrect&quot;};<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; void checkQuestion (int intAnswer);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (intAnswer == 3)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;This answer is &quot; &lt;&lt; result &lt;&lt;endl;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  void checkQuestion (string stringAnswer);<br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (stringAnswer == &quot;Abrahim Lincoln&quot;)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;This answer is &quot; &lt;&lt; result &lt;&lt; endl;<br />
&nbsp;  }<br />
&nbsp;  <br />
&nbsp; void checkQuestion (bool boolAnswer);<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (boolAnswer == true)<br />
&nbsp; {<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;This answer is &quot; &lt;&lt; result &lt;&lt; endl;<br />
&nbsp; }<br />
<br />
system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
}</pre><br />
Voila! Syntax-highlighting!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240297.html</guid>
		</item>
		<item>
			<title>Integer array and memory allocation</title>
			<link>http://www.daniweb.com/forums/thread240295.html</link>
			<pubDate>Sat, 21 Nov 2009 19:09:31 GMT</pubDate>
			<description><![CDATA[Hi, i am making a program that contains an integer array of an unknown size.The user is prompted to enter numbers into the array,and press 'x' to exit. 
 
What i am going to do then,is to pass the  array from the main into a class which contains another array,but before i do that i wanted to...]]></description>
			<content:encoded><![CDATA[<div>Hi, i am making a program that contains an integer array of an unknown size.The user is prompted to enter numbers into the array,and press 'x' to exit.<br />
<br />
What i am going to do then,is to pass the  array from the main into a class which contains another array,but before i do that i wanted to allocate the required space for this array in my class.<br />
<br />
Here is what i have done so far(i have made a small test program with a function instead of included class files)<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#define MAX_SIZE 50<br />
<br />
using namespace std;<br />
<br />
void Malloc(int _array[]);<br />
<br />
<br />
main(){<br />
<br />
&nbsp; int array[MAX_SIZE] = {};<br />
&nbsp; char exit;<br />
<br />
&nbsp; // enter numbers into an array<br />
&nbsp; for(int i = 0; i &lt; MAX_SIZE; i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; &nbsp; // if user enters x program will stop input to array.<br />
&nbsp; &nbsp; &nbsp; if(exit == 'x')<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; cin &gt;&gt; array[i];<br />
&nbsp; }<br />
<br />
&nbsp; for(int i = 0; array[i] != '\0'; i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; array[i];<br />
&nbsp; }<br />
<br />
&nbsp; Malloc(array[]);<br />
<br />
}<br />
<br />
void Malloc(int _array) {<br />
<br />
&nbsp; &nbsp; int size;<br />
&nbsp; &nbsp; int classArray[];<br />
<br />
&nbsp; &nbsp; // Find the size of the array passed in as an argument.<br />
&nbsp; &nbsp; for(size = 0; _array[size] != '\0'; size++);<br />
<br />
<br />
<br />
&nbsp; &nbsp; classArray = (char*)malloc(size+1);<br />
<br />
<br />
&nbsp; &nbsp; for(int i = 0; _array[i] != '\0'; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; classArray[i] = _array[i];<br />
&nbsp; &nbsp; }<br />
<br />
<br />
<br />
}</pre><br />
Does anyone have any suggestions as to what im doing wrong?Any help is appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>StaticX</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240295.html</guid>
		</item>
		<item>
			<title>Need help using the find() function</title>
			<link>http://www.daniweb.com/forums/thread240290.html</link>
			<pubDate>Sat, 21 Nov 2009 18:40:16 GMT</pubDate>
			<description><![CDATA[I have two vectors--one with the name of the class and one with the abbreviation of the class. The name of the class is in the same position of the abbreviation in the different vectors. I want to make it to where if I input "AERO" the output should be Aerospace Engineering using find().]]></description>
			<content:encoded><![CDATA[<div>I have two vectors--one with the name of the class and one with the abbreviation of the class. The name of the class is in the same position of the abbreviation in the different vectors. I want to make it to where if I input &quot;AERO&quot; the output should be Aerospace Engineering using find().</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>reese27</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240290.html</guid>
		</item>
		<item>
			<title>Issues with Point of Sale program</title>
			<link>http://www.daniweb.com/forums/thread240289.html</link>
			<pubDate>Sat, 21 Nov 2009 18:39:48 GMT</pubDate>
			<description>I am trying to write a point of sale program.  I need to display the menu, the operator enters the lunch order.  Total bill is calculated with sales tax, customer payment is accesped and change (if any) is calculated. order summary should be written to a log file that includes the date, time,...</description>
			<content:encoded><![CDATA[<div>I am trying to write a point of sale program.  I need to display the menu, the operator enters the lunch order.  Total bill is calculated with sales tax, customer payment is accesped and change (if any) is calculated. order summary should be written to a log file that includes the date, time, number of items sold, the order total without tax, and the tax amount.  Log file should be displayed.  Then the last order should be cleared and a new order can begin.  At the end of the day the operator will select to &quot;end the program&quot;.  I am very overwhelmed.  Here is what I have so far.  I'm looking for some confirmatio on what I've written and a bump in the right direction of where to go from here.  Sorry, it's kind of messy. If I'm posting this incorrectly could someone please let me know? Thanks.  <br />
<br />
<br />
#include&lt;iostream&gt;<br />
#include&lt;iomanip&gt;<br />
#include&lt;string&gt;<br />
#include&lt;cmath&gt;<br />
<br />
using namespace std;<br />
<br />
//declare function prototypes<br />
displayMenu();<br />
double calctax(double saleAmount, double taxRate);<br />
double calctotal(double saleAmount, double taxAmount);<br />
<br />
<br />
int main()<br />
{<br />
	//declare variables<br />
	int number;<br />
	double sale = 0.00;<br />
	double tax = 0.00;<br />
	double rate = 0.0;<br />
	double sum = 0.00;<br />
	double total = 0.00;<br />
	double quantity = 0.0;<br />
	char response;<br />
	double sumItem = 0.00;<br />
	char menuItem;<br />
<br />
	//display operator choices<br />
	cout &lt;&lt; &quot;Enter 1 to start the data entry mode &quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Enter 2 to display the log file &quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Enter 3 to Quit the program &quot; &lt;&lt; endl;<br />
<br />
	cin &gt;&gt; number;<br />
<br />
	if (number ==1)<br />
		displayMenu;<br />
	else if (number == 2)<br />
		displayLogFile;<br />
	else if (number == 3)<br />
		endProgram;<br />
	else<br />
		cout &lt;&lt; &quot;Invalid Entry&quot; &lt;&lt; endl;<br />
<br />
<br />
	//Ask operator for orders<br />
	cout &lt;&lt; &quot;Enter the first letters of the menu item &quot;;<br />
		 &lt;&lt; &quot;the customer has ordered: &quot;;<br />
	cin &gt;&gt; menuItem;<br />
	cout &lt;&lt; endl;<br />
<br />
	switch (menuItem)<br />
	{<br />
	case 'ha':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 2.29 * quantity;<br />
	break;<br />
	case 'ch':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 2.49 * quantity;<br />
	break;	<br />
	case 'sa':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 3.99 * quantity;<br />
	break;<br />
	case 'fr':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 1.49 * quantity;<br />
	break;<br />
	case 'so':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 1.75 * quantity;<br />
	break;<br />
	case 'la':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 2.49 * quantity;<br />
	break;<br />
	case 'sm':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 1.29 * quantity;<br />
	break;<br />
	case 'ca':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 2.49 * quantity;<br />
	break;<br />
	case 'pi':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 2.29 * quantity;<br />
	break;<br />
	case 'ic': <br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 1.99 * quantity;<br />
	break;<br />
	case 'co': <br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 1.15 * quantity;<br />
	break;<br />
	case 'te':<br />
		cout &lt;&lt; &quot;Enter the quantity ordered: &quot;;<br />
		cin &gt;&gt; quantity;<br />
		cout &lt;&lt; endl;<br />
		sumItem = 1.05 * quantity;<br />
	break;<br />
<br />
	default:<br />
		cout &lt;&lt; &quot;Invalid entry.&quot; &lt;&lt; endl;<br />
	}<br />
<br />
	cout &lt;&lt; &quot;Order another item: Y or N&quot;;<br />
	cin &gt;&gt; response;<br />
	cout &lt;&lt; endl;<br />
<br />
	while ( response == 'Y')<br />
		cout &lt;&lt; &quot;Enter the first letters of the menu item &quot;<br />
			 &lt;&lt; &quot;the customer has ordered: &quot;;<br />
		cin &gt;&gt; menuItem;<br />
		cout &lt;&lt; endl;<br />
	<br />
	//call the tax calculation function<br />
	tax = calctax(sale, rate);<br />
<br />
	//call the total bill function<br />
	total = calctotal(sale, tax);<br />
<br />
	return 0;<br />
}<br />
<br />
void displayMenu()<br />
{<br />
	cout &lt;&lt; &quot;Hamburger     $2.29&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Cheeseburger   2.49&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Sandwich       3.99&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;French Fries   1.49&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Soup           1.75&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Large Drink    2.49&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Small Drink	1.29&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Cake			2.49&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Pie			2.29&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Ice Cream		1.99&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Coffee			1.15&quot; &lt;&lt; endl;<br />
	cout &lt;&lt; &quot;Tea			1.05&quot; &lt;&lt; endl;<br />
}<br />
<br />
//function to calculate sales tax<br />
double calctax(double saleAmount, double taxRate)<br />
{<br />
	return (saleAmount * taxRate);<br />
}<br />
<br />
//function to calculate total sale<br />
double calctotal(double saleAmount, double taxAmount);<br />
{<br />
	return (saleAmount + taxAmount)<br />
}<br />
</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>stefanief</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240289.html</guid>
		</item>
		<item>
			<title>Parameters in OO c++</title>
			<link>http://www.daniweb.com/forums/thread240285.html</link>
			<pubDate>Sat, 21 Nov 2009 18:26:25 GMT</pubDate>
			<description>Hi Im really stuck on one problem. I trying to save some data to a file.  
im using Borland compiler. 
the challenege is to create a new product and save its details to a text file.  
1. the user inputs product details i.e. Barcode, Name, Price, and quantity via the interface 
2. the user clicks on...</description>
			<content:encoded><![CDATA[<div>Hi Im really stuck on one problem. I trying to save some data to a file. <br />
im using Borland compiler.<br />
the challenege is to create a new product and save its details to a text file. <br />
1. the user inputs product details i.e. Barcode, Name, Price, and quantity via the interface<br />
2. the user clicks on save button, and it creates a file to which the information is saved<br />
<br />
heres what ive got so far:<br />
<br />
Product.h file<br />
 <pre style="margin:20px; line-height:13px">class Product<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; private: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AnsiString BarCodeField[];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AnsiString ProductNameField[];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double PriceExVAT;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double PriceIncVAT;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int CurrentSupplyField;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int MinimumSupplyField;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void CreateNewProduct(AnsiString theBarCodeField[],<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AnsiString theProductNameField[],<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double thePriceExVAT,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double thePriceIncVAT,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int theCurrentSupplyField,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int theMinimumSupplyField);<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AnsiString getBarCode();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AnsiString getProductName();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getExVAT();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double getIncVAT();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int getCurrentSupply();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int getMinimumSupply();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Product();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ~Product();<br />
<br />
};</pre><br />
Product.cpp file<br />
 <pre style="margin:20px; line-height:13px">Product::Product()<br />
{<br />
<br />
}<br />
<br />
Product::~Product()<br />
{<br />
<br />
}<br />
<br />
void Product::CreateNewProduct(AnsiString theBarCodeField[],<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AnsiString theProductNameField[],<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double thePriceExVAT,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double thePriceIncVAT,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int theCurrentSupplyField,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int theMinimumSupplyField)<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; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BarCodeField[] = theBarCodeField[];<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ProductNameField[] = theProductNameField[];<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PriceExVAT = thePriceExVAT;<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PriceIncVAT = thePriceIncVAT;<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurrentSupplyField = theCurrentSupplyField;<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
//---------------------------------------------------------------------------<br />
AnsiString Product::getBarCode()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; return BarCodeField[];<br />
}<br />
//---------------------------------------------------------------------------<br />
AnsiString Product::getProductName()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; return ProductNameField[];<br />
}<br />
//---------------------------------------------------------------------------<br />
double Product::getExVAT()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; return PriceExVAT;<br />
}<br />
//---------------------------------------------------------------------------<br />
double Product::getIncVAT()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; return PriceIncVAT;<br />
}<br />
//---------------------------------------------------------------------------<br />
int Product::getCurrentSupply()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; return CurrentSupplyField;<br />
}<br />
//---------------------------------------------------------------------------<br />
<br />
int Product::getMinimumSupply()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; return MinimumSupplyField;<br />
}<br />
//---------------------------------------------------------------------------</pre><br />
<br />
AddProductForm.cpp file<br />
 <pre style="margin:20px; line-height:13px">void __fastcall TForm2::AddToStockClick(TObject *Sender)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE * FSave;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; theProduct.CreateNewProduct(//???????? HELP PLEASE!!!!!!! WHAT PARAMETERS GO HERE???<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //BarcodeBox,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ProductName, <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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ExVAT,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //IncVAT<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //CurrentSupply-&gt;Text,<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //MinimumSupply-&gt;Text<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ); ???<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(theProduct.getBarCode, BarcodeBox-&gt;Text.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //i want to copy the data from a TEdit box into the getBarCode variable and save it to file<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
if(SaveDialog1-&gt;Execute())<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FSave = fopen(SaveDialog1-&gt;FileName.c_str(),&quot;w&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ProdConfirm-&gt;Visible = true;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(FSave == NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox(NULL,&quot;The file could not be saved&quot;,&quot;Error&quot;, MB_OK);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(FSave, &quot;%s\t&quot;, BarCodeField);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(FSave, &quot;%s\t&quot;, ProductNameField);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(FSave, &quot;%.2f\t&quot;, PriceExVAT);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(FSave, &quot;%.2f\t&quot;, PriceIncVAT);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(FSave, &quot;%s\t&quot;, CurrentSupplyField);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(FSave, &quot;%s\t&quot;, MinimumSupplyField);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; fclose(FSave);</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ciganjo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240285.html</guid>
		</item>
		<item>
			<title>How do I disable console output?</title>
			<link>http://www.daniweb.com/forums/thread240284.html</link>
			<pubDate>Sat, 21 Nov 2009 18:20:22 GMT</pubDate>
			<description><![CDATA[I've got a library that is annoying me. When I command it to do what I need it to do, it spits out a bunch of text onto the screen that I don't need.  
Is there a way to temporarily "mute" a console program, then re enable it later? 
 
This is what I have found from Google: 
  <div...]]></description>
			<content:encoded><![CDATA[<div>I've got a library that is annoying me. When I command it to do what I need it to do, it spits out a bunch of text onto the screen that I don't need. <br />
Is there a way to temporarily &quot;mute&quot; a console program, then re enable it later?<br />
<br />
This is what I have found from Google:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp;  std::streambuf* cout_sbuf = std::cout.rdbuf(); // save original sbuf<br />
&nbsp; &nbsp; std::ofstream&nbsp;  fout(&quot;/dev/null&quot;);<br />
&nbsp; &nbsp; std::cout.rdbuf(fout.rdbuf()); // redirect 'cout' to a 'fout'<br />
&nbsp; std::cout.rdbuf(cout_sbuf); // restore the original stream buffer</pre><br />
But that comes up with TONS of errors.<br />
<br />
Any ideas? Thanks guys :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mybluehair</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240284.html</guid>
		</item>
		<item>
			<title>User calling functions in the program</title>
			<link>http://www.daniweb.com/forums/thread240274.html</link>
			<pubDate>Sat, 21 Nov 2009 16:56:36 GMT</pubDate>
			<description><![CDATA[I'm making a graph theory problem solver and basically I made a bunch of functions that will set up the graph and allow the user to modify the graph, but obviously these functions can only be called from the program. The user can't just type the function name and expect the function to be called...]]></description>
			<content:encoded><![CDATA[<div>I'm making a graph theory problem solver and basically I made a bunch of functions that will set up the graph and allow the user to modify the graph, but obviously these functions can only be called from the program. The user can't just type the function name and expect the function to be called unless I do a lot of string parsing. For example, for the function, initGraph(graph *g, bool directed), I have to do the following,<br />
 <pre style="margin:20px; line-height:13px">if (command.length() &gt; 10){<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (command.substr(0, 9) == &quot;initGraph&quot;) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (command.substr(10, 1) == &quot;1&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; directed = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (command.substr(10, 1) == &quot;0&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; directed = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((i &gt;= 0 &amp;&amp; i &lt;= 9) &amp;&amp; (directed == 1 || directed == 0)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g[i] = new graph();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; initGraph(g[i], directed);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre>(Even though my function takes two parameters I only made it so the user has to input one. Most functions require the user to input both parameters.)<br />
I haven't even added the code to make sure there are parenthesis around the parameters and other small details. Other functions also have more complex parameters so string parsing is possible but it is a very long process. Is there a better way to do it without all of this parsing?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>gsingh2011</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240274.html</guid>
		</item>
		<item>
			<title><![CDATA[it's a home work , please help me]]></title>
			<link>http://www.daniweb.com/forums/thread240270.html</link>
			<pubDate>Sat, 21 Nov 2009 16:20:48 GMT</pubDate>
			<description>Write C++ program to do the following: 
 
•	Define a Double Linked Lists EmpRank where the data should be of type integer. 
•	Enter 10 Employee Ranks, where each rank should be inserted in EmpRank with respect to its value as ascending order its ordered  
•	Print out the EmpRank in two ways,...</description>
			<content:encoded><![CDATA[<div>Write C++ program to do the following:<br />
<br />
•	Define a Double Linked Lists EmpRank where the data should be of type integer.<br />
•	Enter 10 Employee Ranks, where each rank should be inserted in EmpRank with respect to its value as ascending order its ordered <br />
•	Print out the EmpRank in two ways, forward and backward, starting from the pointer position<br />
•	Function to delete all ranks which it is not divisible by 3 out how many marks is greater than a user defined mark.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ahmad Shaheen</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240270.html</guid>
		</item>
		<item>
			<title>linker error</title>
			<link>http://www.daniweb.com/forums/thread240261.html</link>
			<pubDate>Sat, 21 Nov 2009 15:45:42 GMT</pubDate>
			<description><![CDATA[i often get linker error  
"undefined symbol _main in the module c0.asm"  
when running the c files .. how can overcome this error]]></description>
			<content:encoded><![CDATA[<div>i often get linker error <br />
&quot;undefined symbol _main in the module c0.asm&quot; <br />
when running the c files .. how can overcome this error</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>SDPRIYA</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240261.html</guid>
		</item>
		<item>
			<title>Code Snippet i need help</title>
			<link>http://www.daniweb.com/code/snippet240259.html</link>
			<pubDate>Sat, 21 Nov 2009 15:38:00 GMT</pubDate>
			<description><![CDATA[Hello everyone i'm a new member , i need ur help with this code ,  
i want to write a for loop that assigns the 3rd row of the array to 0,, and then print out the array after setting the 3rd row to 0.]]></description>
			<content:encoded><![CDATA[<div>Hello everyone i'm a new member , i need ur help with this code , <br />
i want to write a for loop that assigns the 3rd row of the array to 0,, and then print out the array after setting the 3rd row to 0.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Fajer91</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240259.html</guid>
		</item>
		<item>
			<title>Thoughts about Qt</title>
			<link>http://www.daniweb.com/forums/thread240256.html</link>
			<pubDate>Sat, 21 Nov 2009 15:13:10 GMT</pubDate>
			<description><![CDATA[The company that I work for just bought a Qt License, so we've been messing around with it.  So far, it's really nice.  I'm more of a Java guy, and it's made the transition from Java to C++ much easier.  The only real problem I have with it now, is that you pretty much have to use their IDE to...]]></description>
			<content:encoded><![CDATA[<div>The company that I work for just bought a Qt License, so we've been messing around with it.  So far, it's really nice.  I'm more of a Java guy, and it's made the transition from Java to C++ much easier.  The only real problem I have with it now, is that you pretty much have to use their IDE to develop applications with it.<br />
<br />
So, my question is, what do you think of Qt?<br />
<a rel="nofollow" class="t" href="http://qt.nokia.com/" target="_blank">Qt Libraries</a></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>llemes4011</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240256.html</guid>
		</item>
		<item>
			<title>inp(),outp()</title>
			<link>http://www.daniweb.com/forums/thread240245.html</link>
			<pubDate>Sat, 21 Nov 2009 14:19:32 GMT</pubDate>
			<description>Hi!  
I am an engineering student.I was exploring the conio.h file in c++ when i encountered inp(),outp() functions. I understood the basics about them but i am still not able to create a meaningful program with it.Somebody please help me !</description>
			<content:encoded><![CDATA[<div>Hi! <br />
I am an engineering student.I was exploring the conio.h file in c++ when i encountered inp(),outp() functions. I understood the basics about them but i am still not able to create a meaningful program with it.Somebody please help me !</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jaskaran.nagra</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240245.html</guid>
		</item>
		<item>
			<title>0xC0000005 Error on Array</title>
			<link>http://www.daniweb.com/forums/thread240243.html</link>
			<pubDate>Sat, 21 Nov 2009 13:47:16 GMT</pubDate>
			<description><![CDATA[Hello everyone, 
 
I have used the Vector2 Class which is implemented by my asst. , 
and I encountered a problem with initializing it. 
 
VS2008 kept saying I violate 0xC0000005 Error, and I counldn't find any reason for this. 
 
Is there anyone who can tell me what mistakes I have made? 
 
Thank...]]></description>
			<content:encoded><![CDATA[<div>Hello everyone,<br />
<br />
I have used the Vector2 Class which is implemented by my asst. ,<br />
and I encountered a problem with initializing it.<br />
<br />
VS2008 kept saying I violate 0xC0000005 Error, and I counldn't find any reason for this.<br />
<br />
Is there anyone who can tell me what mistakes I have made?<br />
<br />
Thank you.<br />
<br />
Hong <br />
<br />
 <pre style="margin:20px; line-height:13px">Vector2&lt;float&gt; m_pVec2Stage[150];<br />
/*<br />
...<br />
*/<br />
<br />
for(int n = 0; n&lt;150; n++)<br />
&nbsp; &nbsp; &nbsp;  m_pVec2Stage[n] = Vector2&lt;float&gt;(0,0);<br />
<br />
<br />
<br />
/*<br />
...<br />
*/<br />
<br />
template &lt;typename T&gt;<br />
Vector2&lt;T&gt; &amp;Vector2&lt;T&gt;::set (const Vector2 &amp;d) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = d[0];<br />
&nbsp; &nbsp; &nbsp; &nbsp; y = d[1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; return (*this);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>zephy2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240243.html</guid>
		</item>
		<item>
			<title>Qt Media Player</title>
			<link>http://www.daniweb.com/forums/thread240238.html</link>
			<pubDate>Sat, 21 Nov 2009 13:21:52 GMT</pubDate>
			<description><![CDATA[I'm creating a media player with Qt & the phonon module: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with...]]></description>
			<content:encoded><![CDATA[<div>I'm creating a media player with Qt &amp; the phonon module:<br />
 <pre style="margin:20px; line-height:13px">#include &quot;mainwindow.h&quot;<br />
#include &quot;ui_mainwindow.h&quot;<br />
#include &lt;fstream&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;QtGui&gt;<br />
<br />
void MainWindow::slotFinished(){<br />
&nbsp; &nbsp; int index = sources.indexOf(mediaObject-&gt;currentSource()) + 1;<br />
&nbsp; &nbsp; mediaObject-&gt;enqueue(sources.at(index));<br />
&nbsp; &nbsp; setLabelNowPlaying();<br />
}<br />
<br />
std::string ExtractFilename( const std::string&amp; path )<br />
{<br />
&nbsp; return path.substr( path.find_last_of( '/' ) +1 );<br />
}<br />
<br />
<br />
void MainWindow::setLabel(const QString &amp;s){<br />
&nbsp; &nbsp; ui-&gt;label-&gt;setText(s);<br />
&nbsp; &nbsp; //qDebug() &lt;&lt; &quot;s = &quot; &lt;&lt; s;<br />
<br />
}<br />
<br />
void MainWindow::setLabelNowPlaying(){<br />
&nbsp; &nbsp; std::string stds;<br />
&nbsp; &nbsp; stds = &quot;Now playing: &quot;;<br />
&nbsp; &nbsp; std::string filename;<br />
&nbsp; &nbsp; filename = mediaObject-&gt;currentSource().fileName().toStdString();<br />
<br />
&nbsp; &nbsp; std::string file;<br />
<br />
&nbsp; &nbsp; file = ExtractFilename(filename);<br />
<br />
&nbsp; &nbsp; stds += file;<br />
&nbsp; &nbsp; setLabel( QString::fromStdString( stds ) );<br />
}<br />
<br />
void MainWindow::loadfromfile(std::string filename){<br />
&nbsp; &nbsp; try{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  std::ifstream file(filename.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if (file.is_open()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char str[2000];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  bool firsttime = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int index;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  while(!file.eof()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; file.getline(str,2000);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (firsttime){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = atoi(str);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (index == -1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; &quot;ahh\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; firsttime = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Phonon::MediaSource source(str);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sources.append(source);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::cout &lt;&lt; str &lt;&lt; &quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (!firsttime){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaObject-&gt;setCurrentSource(sources.at(index));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  }catch (int a){}<br />
}<br />
<br />
void MainWindow::saveToFile(std::string filename){<br />
&nbsp; &nbsp; std::ofstream file(filename.c_str());<br />
&nbsp; &nbsp; file &lt;&lt; sources.indexOf(mediaObject-&gt;currentSource()) &lt;&lt; &quot;\n&quot;;<br />
&nbsp; &nbsp; foreach(Phonon::MediaSource s, sources){<br />
&nbsp; &nbsp; &nbsp; &nbsp; file &lt;&lt; s.fileName().toStdString() &lt;&lt; &quot;\n&quot;;<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
MainWindow::MainWindow(QWidget *parent)<br />
&nbsp; &nbsp; : QMainWindow(parent), ui(new Ui::MainWindow)<br />
{<br />
&nbsp; &nbsp;  audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);<br />
&nbsp; &nbsp;  mediaObject = new Phonon::MediaObject(this);<br />
&nbsp; &nbsp;  metaInformationResolver = new Phonon::MediaObject(this);<br />
&nbsp; &nbsp;  Phonon::createPath(mediaObject, audioOutput);<br />
&nbsp; &nbsp;  connect(mediaObject, SIGNAL(aboutToFinish()), SLOT(slotFinished()));<br />
<br />
&nbsp; &nbsp;  std::string home = getenv(&quot;HOME&quot;);<br />
&nbsp; &nbsp;  home += &quot;/.mped/default.session&quot;;<br />
&nbsp; &nbsp;  std::cout &lt;&lt; home &lt;&lt; &quot;\n&quot;;<br />
<br />
&nbsp; &nbsp;  try{<br />
&nbsp; &nbsp; &nbsp; &nbsp; loadfromfile(home);<br />
&nbsp; &nbsp;  }catch (int a){<br />
&nbsp; &nbsp;  }<br />
<br />
&nbsp; &nbsp;  ui-&gt;setupUi(this);<br />
&nbsp; &nbsp;  statusBar()-&gt;showMessage(&quot;Imported default.session&quot;,7000);<br />
<br />
}<br />
<br />
void MainWindow::playPause()<br />
{<br />
&nbsp; &nbsp; switch (mediaObject-&gt;state()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; case Phonon::PlayingState:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaObject-&gt;pause();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ui-&gt;pushButtonPlay-&gt;setChecked(false);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setLabel(&quot;Paused&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case Phonon::PausedState:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaObject-&gt;play();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setLabelNowPlaying();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case Phonon::StoppedState:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaObject-&gt;play();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setLabelNowPlaying();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case Phonon::LoadingState:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ui-&gt;pushButtonPlay-&gt;setChecked(false);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setLabel(&quot;Paused&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
void MainWindow::addFiles()<br />
{<br />
&nbsp; &nbsp; QStringList files = QFileDialog::getOpenFileNames(this, tr(&quot;Select Music Files&quot;),<br />
&nbsp; &nbsp; &nbsp; &nbsp; QDesktopServices::storageLocation(QDesktopServices::MusicLocation));<br />
<br />
&nbsp; &nbsp; ui-&gt;pushButtonPlay-&gt;setChecked(false);<br />
&nbsp; &nbsp; if (files.isEmpty())<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; int index = sources.size();<br />
&nbsp; &nbsp; foreach (QString string, files) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Phonon::MediaSource source(string);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sources.append(source);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; if (!sources.isEmpty()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; metaInformationResolver-&gt;setCurrentSource(sources.at(0));<br />
&nbsp; &nbsp; &nbsp; &nbsp; mediaObject-&gt;setCurrentSource(metaInformationResolver-&gt;currentSource());<br />
<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
<br />
void MainWindow::nextFile()<br />
{<br />
<br />
&nbsp; &nbsp; int index = sources.indexOf(mediaObject-&gt;currentSource()) + 1;<br />
<br />
&nbsp; &nbsp; if (sources.size() &gt; index) {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mediaObject-&gt;stop();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mediaObject-&gt;setCurrentSource(sources.at(index));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mediaObject-&gt;play();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  setLabelNowPlaying();<br />
&nbsp; &nbsp;  }<br />
}<br />
<br />
void MainWindow::lastFile(){<br />
&nbsp; &nbsp; int index = sources.indexOf(mediaObject-&gt;currentSource()) - 1;<br />
<br />
&nbsp; &nbsp; mediaObject-&gt;stop();<br />
&nbsp; &nbsp; try{<br />
&nbsp; &nbsp; mediaObject-&gt;setCurrentSource(sources.at(index));<br />
&nbsp; &nbsp; }catch(int e){}<br />
&nbsp; &nbsp; mediaObject-&gt;play();<br />
&nbsp; &nbsp; setLabelNowPlaying();<br />
}<br />
<br />
void MainWindow::shuffle(){<br />
&nbsp; &nbsp; mediaObject-&gt;stop();<br />
&nbsp; &nbsp; std::random_shuffle(sources.begin(), sources.end());<br />
&nbsp; &nbsp; mediaObject-&gt;setCurrentSource(sources.at(0));<br />
&nbsp; &nbsp; setLabel(&quot;Paused&quot;);<br />
&nbsp;}<br />
<br />
void MainWindow::clear(){<br />
&nbsp; &nbsp; mediaObject-&gt;stop();<br />
&nbsp; &nbsp; sources.clear();<br />
&nbsp; &nbsp; setLabel(&quot;Paused&quot;);<br />
}<br />
<br />
void MainWindow::first(){<br />
&nbsp; &nbsp; mediaObject-&gt;stop();<br />
&nbsp; &nbsp; mediaObject-&gt;setCurrentSource(sources.at(0));<br />
&nbsp; &nbsp; mediaObject-&gt;play();<br />
&nbsp; &nbsp; setLabelNowPlaying();<br />
}<br />
<br />
void MainWindow::open(){<br />
&nbsp; &nbsp; QString filename = QFileDialog::getOpenFileName(this, tr(&quot;Select session file&quot;),<br />
&nbsp; &nbsp; &nbsp; &nbsp; QDesktopServices::storageLocation(QDesktopServices::MusicLocation));<br />
&nbsp; &nbsp; if (filename == &quot;&quot; || filename == NULL){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp;  loadfromfile(filename.toStdString());<br />
&nbsp; &nbsp;  mediaObject-&gt;setCurrentSource(sources.at(0));<br />
}<br />
<br />
void MainWindow::save(){<br />
&nbsp; &nbsp; QString filename = QFileDialog::getOpenFileName(this, tr(&quot;Select session file&quot;),<br />
&nbsp; &nbsp; &nbsp; &nbsp; QDesktopServices::storageLocation(QDesktopServices::MusicLocation));<br />
&nbsp; &nbsp; if (filename == &quot;&quot; || filename == NULL){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; saveToFile(filename.toStdString());<br />
}<br />
<br />
void MainWindow::about(){<br />
&nbsp; &nbsp; QMessageBox::about(this,&quot;About MPED&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;MPED 0.1\n\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;MPED was written by Matthew Hall &lt;pymatio@googlemail.com&gt;\n\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;MPED is release under the GPL.\n&quot;);<br />
<br />
}<br />
<br />
void MainWindow::aboutToFinish()<br />
{<br />
<br />
&nbsp; &nbsp; int index = sources.indexOf(mediaObject-&gt;currentSource()) + 1;<br />
<br />
&nbsp; &nbsp;  if (sources.size() &gt; index) {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mediaObject-&gt;enqueue(sources.at(index));<br />
&nbsp; &nbsp;  } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  ui-&gt;pushButtonPlay-&gt;setChecked(false);<br />
&nbsp; &nbsp;  }<br />
<br />
}<br />
<br />
void MainWindow::finished()<br />
{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  ui-&gt;pushButtonPlay-&gt;setChecked(false);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  setLabel(&quot;Paused&quot;);<br />
<br />
}<br />
<br />
<br />
<br />
MainWindow::~MainWindow()<br />
{<br />
&nbsp; &nbsp; std::string home = getenv(&quot;HOME&quot;);<br />
&nbsp; &nbsp; home += &quot;/.mped/default.session&quot;;<br />
&nbsp; &nbsp; std::ofstream file(home.c_str());<br />
&nbsp; &nbsp; file &lt;&lt; sources.indexOf(mediaObject-&gt;currentSource()) &lt;&lt; &quot;\n&quot;;<br />
&nbsp; &nbsp; foreach(Phonon::MediaSource s, sources){<br />
&nbsp; &nbsp; &nbsp; &nbsp; file &lt;&lt; s.fileName().toStdString() &lt;&lt; &quot;\n&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; delete ui;<br />
}</pre>when run if you press the next button twice it stays on the same track, also it sometimes jumps to tracks along, why?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>pymatio</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240238.html</guid>
		</item>
		<item>
			<title>Protecting code from decompilation</title>
			<link>http://www.daniweb.com/forums/thread240225.html</link>
			<pubDate>Sat, 21 Nov 2009 11:55:05 GMT</pubDate>
			<description><![CDATA[Is there any language or way to write a program that is about 10000 lines in such a way that it can't be re-engineered by decompiling it ? What options are available to pursue ? 
 
Thank you for your time..]]></description>
			<content:encoded><![CDATA[<div>Is there any language or way to write a program that is about 10000 lines in such a way that it can't be re-engineered by decompiling it ? What options are available to pursue ?<br />
<br />
Thank you for your time..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>dchunt</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240225.html</guid>
		</item>
		<item>
			<title>Hello Everyone</title>
			<link>http://www.daniweb.com/forums/thread240223.html</link>
			<pubDate>Sat, 21 Nov 2009 11:36:40 GMT</pubDate>
			<description>Hi, my name is Jonathan. I am 20 years old and I have just started getting into programming in the C++ language (you must get this alot). I do know a couple of programming languages already. 
 
Now before I waste your time let me just say that there is no question in this post. The purpose of this...</description>
			<content:encoded><![CDATA[<div>Hi, my name is Jonathan. I am 20 years old and I have just started getting into programming in the C++ language (you must get this alot). I do know a couple of programming languages already.<br />
<br />
Now before I waste your time let me just say that there is no question in this post. The purpose of this thread is mainly just for me to introduce myself, explain why I am here and give you a brief introduction of my programming goals.<br />
<br />
<br />
These are the reasons I want to learn C++:<br />
<br />
First off, is the ability to create programs that run independently from an Operating System. I am in the process of creating my own boot disk to handle tasks that I commonly have to do before I do Windows installations for &quot;fixing&quot; computers. Also I am interested in creating a Windows-based service for a networking program idea I have. That and, well I have been wanting to learn this language for years now lol ;)<br />
<br />
I am going to be working on some pretty interesting program ideas. Most of my program ideas do not currently exist and I think one of them has the potential to completely change the way personal computers are used on a home network (only if mass-distributed of course). Another program idea I have could save hours when formatting/reinstalling Windows on a computer by backing up things like personal settings, product keys, files/documents, activation information, drivers and maybe even full-fledged programs. I think you can understand how C++ could help me.<br />
<br />
I am a very independent learner so you will not have to worry about me too much. That isn't to say that I won't accept help. If anybody at any time is interested in co-developing any one of my programs I am more than happy to accept. Also, feel free to ask questions about any of my ideas.<br />
<br />
Thank you for reading, and I hope your day turns out as awesome as mine was. =D</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>FanatiK</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240223.html</guid>
		</item>
		<item>
			<title>how to include mhash library in turbo c++</title>
			<link>http://www.daniweb.com/forums/thread240221.html</link>
			<pubDate>Sat, 21 Nov 2009 11:32:15 GMT</pubDate>
			<description>i have downloaded mhah library and i tried to include it in turbo c++ i copied the folder to the turbo c++ when i tried to run the c files in the library i found 5 errors  
cant able to include mutils/mincludes.h... mutils/mtypes.h... mutils/global.h...  mutils/mhash.h... libdefs.h 
mutils folder...</description>
			<content:encoded><![CDATA[<div>i have downloaded mhah library and i tried to include it in turbo c++ i copied the folder to the turbo c++ when i tried to run the c files in the library i found 5 errors <br />
cant able to include mutils/mincludes.h... mutils/mtypes.h... mutils/global.h...  mutils/mhash.h... libdefs.h<br />
mutils folder is found inside include folder the mhash library .. what should i do to include these files..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>SDPRIYA</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240221.html</guid>
		</item>
		<item>
			<title>Need C++ code</title>
			<link>http://www.daniweb.com/forums/thread240216.html</link>
			<pubDate>Sat, 21 Nov 2009 11:16:30 GMT</pubDate>
			<description>Problem Statement: File Handling in C/C++ 
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen 
A college has announced the total budget of 50,000Rs.for each game. Games are done four times in a year. Take...</description>
			<content:encoded><![CDATA[<div>Problem Statement: File Handling in C/C++<br />
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen<br />
A college has announced the total budget of 50,000Rs.for each game. Games are done four times in a year. Take expenses as an input from user. <br />
Calculate the average expenses for a game:<br />
<br />
<br />
<br />
<br />
<br />
1.	If the expenses greater than 80% show as” Very Expensive”.<br />
2.	If the expenses  are greater than 60% and less than 80% than show “Expensive ”<br />
3.	If the expenses  are greater than 50% and less than 60% than show “Less Expensive ”<br />
4.	If the expenses are greater than 40% and less than 50% than show “Not Costly”.<br />
5.	If the expenses are less than 40% than show “Best”.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ihtesham4deni</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240216.html</guid>
		</item>
		<item>
			<title>Generalized matrix inverse method for balancing chemical equation and their stability</title>
			<link>http://www.daniweb.com/forums/thread240215.html</link>
			<pubDate>Sat, 21 Nov 2009 09:27:24 GMT</pubDate>
			<description><![CDATA[Hi, 
Its my first project. I have to develop a c program which can balance a chemical equation by the method of 'Generalized matrix inverse method for balancing chemical equation and their stability'. 
But I am using a little different method. where I am not able to find complete step to find rank...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
Its my first project. I have to develop a c program which can balance a chemical equation by the method of 'Generalized matrix inverse method for balancing chemical equation and their stability'.<br />
But I am using a little different method. where I am not able to find complete step to find rank of a matrix. I don't be able to develop the algorithm for that.<br />
<br />
Main Qus:<br />
starting from a normal matrix how I can make its a part(few columns) a unit matrix by just Adding &amp; Subtracting Rows of that matrix.<br />
Example:<br />
main matrix:<br />
1 0 0 -1 0 1 0 0 0<br />
2 1 1 -3 0 0 1 0 0<br />
0 1 2 -1-1 0 0 1 0<br />
0 1 0  0-1 0 0 0 1<br />
<br />
After operation:(r2-2r1;r3-r2;r4-r2;r2-r3;r4+r3;r1+r4;r2+r4)<br />
1 0 0 0 -2 5 -2 1 1<br />
0 1 0 0 -1 0  0 0 1<br />
0 0 1 0 -1 2 -1 1 0<br />
0 0 0 1 -2 4 -2 1 1<br />
please help me as soon as possible....Rahul</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>rahul.nutron</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240215.html</guid>
		</item>
		<item>
			<title>Countdown Timer Forms</title>
			<link>http://www.daniweb.com/forums/thread240198.html</link>
			<pubDate>Sat, 21 Nov 2009 09:12:51 GMT</pubDate>
			<description>hey 
 
just wondering how i can make a countdown timer in a windows forms app 
 
or just how to display an updating value onto the form. 
 
wanted to make a countdown for number of seconds the user inputs. 
 
thnx.</description>
			<content:encoded><![CDATA[<div>hey<br />
<br />
just wondering how i can make a countdown timer in a windows forms app<br />
<br />
or just how to display an updating value onto the form.<br />
<br />
wanted to make a countdown for number of seconds the user inputs.<br />
<br />
thnx.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>evilguyme</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240198.html</guid>
		</item>
		<item>
			<title><![CDATA[[Linker error] undefined reference to...]]></title>
			<link>http://www.daniweb.com/forums/thread240187.html</link>
			<pubDate>Sat, 21 Nov 2009 08:08:45 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">////////////////////////<br />
/////counter.h file/////<br />
////////////////////////<br />
#ifndef _COUNTER_H<br />
#define _COUNTER_H<br />
class Counter{<br />
<br />
&nbsp; &nbsp; private:<br />
&nbsp; &nbsp; &nbsp;  int counter;<br />
&nbsp; &nbsp; &nbsp;  int limit;<br />
&nbsp; &nbsp; &nbsp;  static int nCounters;<br />
&nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Counter(int arg, int arg);<br />
&nbsp; &nbsp; &nbsp; &nbsp; void increment();<br />
&nbsp; &nbsp; &nbsp; &nbsp; void decrement();<br />
&nbsp; &nbsp; &nbsp; &nbsp; int getValue();<br />
&nbsp; &nbsp; &nbsp; &nbsp; static int getNCounters();<br />
};<br />
#include &quot;counter.cpp&quot;<br />
#endif<br />
<br />
//////////////////////////<br />
/////counter.cpp file/////<br />
//////////////////////////<br />
#include &lt;string&gt;<br />
#include &quot;counter.h&quot;<br />
<br />
Counter::Counter(int a, int b){<br />
&nbsp;  counter=a;<br />
&nbsp;  limit=b;<br />
&nbsp;  if (&amp;nCounters==NULL){<br />
&nbsp;  nCounters=0;<br />
&nbsp;  }&nbsp; <br />
&nbsp;  nCounters++;<br />
}<br />
<br />
void Counter::increment()<br />
{<br />
&nbsp; &nbsp; if (counter&lt;limit) counter++;<br />
<br />
&nbsp;}<br />
void Counter::decrement()<br />
{<br />
&nbsp; if(counter&gt;0) counter--;<br />
}<br />
<br />
int Counter::getValue(){<br />
return counter;<br />
}<br />
<br />
int Counter::getNCounters(){<br />
int dummy=nCounters;<br />
return dummy;<br />
}</pre><br />
I'm getting a linker error every time I try to access nCounters.<br />
so i get this result when compiling:<br />
  [Linker error] undefined reference to `Counter::nCounters' <br />
  [Linker error] undefined reference to `Counter::nCounters' <br />
  [Linker error] undefined reference to `Counter::nCounters' <br />
  ld returned 1 exit status</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bamcclur</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240187.html</guid>
		</item>
		<item>
			<title>can anybody help me with this problem?</title>
			<link>http://www.daniweb.com/forums/thread240172.html</link>
			<pubDate>Sat, 21 Nov 2009 06:24:39 GMT</pubDate>
			<description><![CDATA[i keeps getting error i going to break my head to solve this problem =.= 
 
what i am doing is using the a[3][3] to minus 128 but seem i get the problem in minus 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>i keeps getting error i going to break my head to solve this problem =.=<br />
<br />
what i am doing is using the a[3][3] to minus 128 but seem i get the problem in minus<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;cmath&gt;<br />
#include &lt;cstdlib&gt;<br />
using namespace std;<br />
<br />
double shifted_block(double array[3][3]);<br />
<br />
<br />
int main ()<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
// input number in 3X3 array<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; double a[3][3];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; double zero_zero;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+0)[0] = zero_zero;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double zero_one;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+0)[1] = zero_one;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double zero_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+0)[2] = zero_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter 1st row&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; zero_zero &gt;&gt; zero_one &gt;&gt; zero_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; double&nbsp; one_zero;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+1)[0] = one_zero;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double one_one;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+1)[1] = one_one;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double one_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+1)[2] = one_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter 2nd row&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; one_zero &gt;&gt; one_one &gt;&gt; one_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; double two_zero;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+2)[0] = two_zero;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double two_one;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+2)[1] = two_one;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double two_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(a+2)[2] = two_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;enter 3nd row&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; two_zero &gt;&gt; two_one &gt;&gt; two_two;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; zero_zero &lt;&lt; &quot; &quot; &lt;&lt; zero_one &lt;&lt; &quot; &quot; &lt;&lt; zero_two &lt;&lt; &quot; &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; one_zero&nbsp; &lt;&lt; &quot; &quot; &lt;&lt; one_one&nbsp; &lt;&lt; &quot; &quot; &lt;&lt; one_two&nbsp; &lt;&lt; &quot; &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; two_zero &lt;&lt; &quot; &quot; &lt;&lt; two_one &lt;&lt; &quot; &quot; &lt;&lt; two_two &lt;&lt; &quot; &quot; &lt;&lt; endl;<br />
<br />
//display out<br />
<br />
&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; cout &lt;&lt; shifted_block(zero_zero) &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
// to minus 128 of the value input<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
double shifted_block(double array[3][3])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int countrow = 0; countrow &lt; 3; countrow++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; for (int countcolumn = 0; countcolumn &lt; 3; countcolumn++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; return array[countrow][countcolumn] = array[countrow][countcolumn] - 128;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
}<br />
<br />
<br />
<br />
<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bestnone</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240172.html</guid>
		</item>
		<item>
			<title>pthread_create call fell into a black hole</title>
			<link>http://www.daniweb.com/forums/thread240169.html</link>
			<pubDate>Sat, 21 Nov 2009 06:12:18 GMT</pubDate>
			<description><![CDATA[Hi, 
 
The problem I am facing is that I don't understand the code mentioned in the following: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
The problem I am facing is that I don't understand the code mentioned in the following:<br />
<br />
 <pre style="margin:20px; line-height:13px">25: /******** this is the main thread's code */<br />
26: int main(int argc, char *argv[])<br />
27: {<br />
28:&nbsp;  int i;<br />
29:&nbsp;  int retvals[NTHREADS];<br />
30: <br />
31:&nbsp;  /* init retvals */<br />
32:&nbsp;  for (i=0; i&lt;NTHREADS; i++) retvals[i]=-1;<br />
33: <br />
34:&nbsp;  /* do it */<br />
35:&nbsp;  <span style="font-weight:bold">pt_fork(NTHREADS,&nbsp; &nbsp; /* # of threads to create&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */<br />
36:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  hola,&nbsp; &nbsp; &nbsp; &nbsp; /* routine they execute&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */<br />
37:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  retvals,&nbsp; &nbsp;  /* a piece of global data they all share */<br />
38:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  NULL);&nbsp; &nbsp; &nbsp;  /* ignore exit codes&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  */</span><br />
39: <br />
40:&nbsp;  /* check return values */<br />
41:&nbsp;  for (i=0; i&lt;NTHREADS; i++)<br />
42:&nbsp; &nbsp;  if (retvals[i]!=i) {<br />
43:&nbsp; &nbsp; &nbsp;  fprintf(stderr,&quot;thread %d didn't return a value\n&quot;,i);<br />
44:&nbsp; &nbsp; &nbsp;  exit(1);<br />
45:&nbsp; &nbsp;  }<br />
46:&nbsp;  return(0);<br />
47: }</pre><br />
The pt_fork's source is given as:<br />
<br />
[<a rel="nofollow" class="t" href="http://math.arizona.edu/~swig/documentation/pthreads/pt.h]" target="_blank">http://math.arizona.edu/~swig/docume...pthreads/pt.h]</a><br />
 <pre style="margin:20px; line-height:13px">extern void _pt_fork(int nthreads,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  pt_startroutine_t start,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  pt_addr_t arg,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  pt_addr_t *exitcodes);<br />
<br />
#define pt_fork(nt,start,arg,codes) \<br />
&nbsp; _pt_fork(nt,(pt_startroutine_t) start, \<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (pt_addr_t) arg,(pt_addr_t *) codes)</pre><br />
As can be seen from the &quot;pt.h&quot;, the function body of _pt_fork is empty. I am not convinced where the pthread_create is being called from within _pt_fork. Ultimately, threads must be created by calling pthread_create. But the main function above calls the pt_fork(), and the call to pthread_create seems to go into a black hole defined by pt_fork.<br />
<br />
Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>johndoe444</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240169.html</guid>
		</item>
		<item>
			<title><![CDATA[I can't understand.]]></title>
			<link>http://www.daniweb.com/forums/thread240166.html</link>
			<pubDate>Sat, 21 Nov 2009 05:59:28 GMT</pubDate>
			<description>Plz help me. I am unable to understand this problem statement. Can Plz someone help me? 
 
 
*Problem Statement: File Handling in C/C++* 
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen 
A college has...</description>
			<content:encoded><![CDATA[<div>Plz help me. I am unable to understand this problem statement. Can Plz someone help me?<br />
<br />
<br />
<span style="font-weight:bold">Problem Statement: File Handling in C/C++</span><br />
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen<br />
A college has announced the total budget of 50,000Rs.for each game. Games are done four times in a year. Take expenses as an input from user. <br />
Calculate the average expenses for a game:<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-weight:bold">1.</span>	If the expenses greater than 80% show as” Very Expensive”.<br />
<span style="font-weight:bold">2.</span>	If the expenses  are greater than 60% and less than 80% than show “Expensive ”<br />
<span style="font-weight:bold">3.</span>	If the expenses  are greater than 50% and less than 60% than show “Less Expensive ”<br />
<span style="font-weight:bold">4.</span>	If the expenses are greater than 40% and less than 50% than show “Not Costly”.<br />
<span style="font-weight:bold">5.</span>	If the expenses are less than 40% than show “Best”.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>zemly</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240166.html</guid>
		</item>
		<item>
			<title>DirectX 9 Help Needed.</title>
			<link>http://www.daniweb.com/forums/thread240160.html</link>
			<pubDate>Sat, 21 Nov 2009 04:59:31 GMT</pubDate>
			<description>How do I load 3D meshes from a .x file, and extract the material data from it? Also, how do I apply a texture to the loaded mesh?</description>
			<content:encoded><![CDATA[<div>How do I load 3D meshes from a .x file, and extract the material data from it? Also, how do I apply a texture to the loaded mesh?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>tomtetlaw</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240160.html</guid>
		</item>
		<item>
			<title>Check each input integer digit by digit</title>
			<link>http://www.daniweb.com/forums/thread240157.html</link>
			<pubDate>Sat, 21 Nov 2009 04:57:03 GMT</pubDate>
			<description>I am having an issue. I need to check whether the user enters a digit greater than 0. If so the user needs to be reprompted.  If 23409932 is entered then the 0 entered should be caught and the proper messaage displayed. Here is my code and please somebody help. 
 
 
int userInput (int numberInput)...</description>
			<content:encoded><![CDATA[<div>I am having an issue. I need to check whether the user enters a digit greater than 0. If so the user needs to be reprompted.  If 23409932 is entered then the 0 entered should be caught and the proper messaage displayed. Here is my code and please somebody help.<br />
<br />
<br />
int userInput (int numberInput)<br />
<br />
{   <br />
    int index;<br />
    int remains;<br />
    <br />
    cout &lt;&lt; endl;<br />
    cout &lt;&lt; &quot; Enter a positive number count: &quot;;<br />
    cin  &gt;&gt; numberInput;<br />
    <br />
    while (numberInput &gt; 0) {<br />
       index = numberInput % 10;<br />
    <br />
       if (index == 0) {<br />
          cout &lt;&lt; &quot; Error! Enter a positive number count: &quot;;<br />
          cin  &gt;&gt; numberInput;<br />
          numberInput = numberInput / 10;<br />
       }<br />
       else {<br />
          return numberInput;<br />
       }<br />
    }</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>drake2212</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240157.html</guid>
		</item>
		<item>
			<title>Function problems</title>
			<link>http://www.daniweb.com/forums/thread240153.html</link>
			<pubDate>Sat, 21 Nov 2009 04:21:49 GMT</pubDate>
			<description><![CDATA[In this code I want to have a function to show average of movies saw by students, how to define and declare and call it in this program: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>In this code I want to have a function to show average of movies saw by students, how to define and declare and call it in this program:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
<br />
using namespace std;<br />
<br />
/****************Function Prototypes******************/<br />
<br />
void displayList(int [], int);&nbsp; &nbsp; &nbsp; &nbsp;  //function to display array<br />
<br />
void getAverage (int [], int);&nbsp; &nbsp; &nbsp; &nbsp; <br />
void getMedian (int [] , int);<br />
int getMode (int [], int);<br />
<br />
<br />
/***************main***********************/<br />
<br />
int main()<br />
{<br />
&nbsp;  int *movies, <br />
&nbsp; &nbsp; &nbsp; &nbsp; total = 0, <br />
&nbsp; &nbsp; &nbsp; &nbsp; average,<br />
&nbsp; &nbsp; &nbsp; &nbsp; numDays,<br />
&nbsp; &nbsp; &nbsp; &nbsp; count,<br />
&nbsp; &nbsp; &nbsp; &nbsp; numStudent;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // desired size of the array 'students'<br />
&nbsp; &nbsp; &nbsp; &nbsp; int* students = NULL;&nbsp; &nbsp; &nbsp; &nbsp; // pointer to an int, initially to nothing<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;&nbsp; *** Student Movie Analysis ***\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter the number of Students: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; numStudent;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // ** Dynamic allocation of Array size 'n' **<br />
&nbsp; &nbsp; &nbsp; &nbsp; students = new int[numStudent];&nbsp; &nbsp; &nbsp; &nbsp; // Allocate 'numStudent' ints and save in ptr 'students'<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;numStudent; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; students[i] = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // initialize all elements to zero<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; Get the number of movies from the user<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Enter the num. of movies&nbsp; below.\n&quot;;<br />
&nbsp;  <br />
&nbsp; &nbsp;  for (count = 0; count &lt; numStudent; count++)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp;  cout &lt;&lt; &quot;Student # &quot; &lt;&lt; (count + 1) &lt;&lt; &quot; : &quot;;<br />
&nbsp; &nbsp;  cin &gt;&gt; students[count];<br />
&nbsp; &nbsp;  }<br />
<br />
&nbsp;  //Calculate the total movies<br />
&nbsp; &nbsp; &nbsp; for (count = 0; count &lt; numStudent; count++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += students[count];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
//Calculate the average movies per month<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  average = total / numStudent;&nbsp; <br />
&nbsp; &nbsp;  <br />
//Display the results<br />
<br />
cout &lt;&lt; &quot;\n\nTotal Movies: &quot; &lt;&lt; total &lt;&lt; endl;<br />
cout &lt;&lt; &quot;Average : &quot;&lt;&lt; average &lt;&lt; endl; */<br />
<br />
delete [] students;&nbsp; &nbsp; &nbsp; &nbsp; // When done, free memory pointed to by 'students'<br />
&nbsp; &nbsp; &nbsp; &nbsp; students = NULL;&nbsp; &nbsp; &nbsp; &nbsp; // Clear 'students' to prevent invalid memory reference<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;End of Program.\n&quot;;<br />
&nbsp;  system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
here is my average Function but it shows overloading error why i dont know<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">void getAverage( int list[], int numStudent)<br />
{<br />
&nbsp; &nbsp; &nbsp; for (count = 0; count &lt; numStudent; count++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += students[count];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  // Calculate the average movies in a month<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  average = total / numStudent;</pre><br />
<br />
how to call it @ main</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>rafta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240153.html</guid>
		</item>
		<item>
			<title>Insertion Sort Issues</title>
			<link>http://www.daniweb.com/forums/thread240141.html</link>
			<pubDate>Sat, 21 Nov 2009 02:41:53 GMT</pubDate>
			<description><![CDATA[Hi all,  
 
I'm having a heck of a time with our latest assignment.  I've tried everything I can possibly think if to make this work, but with no luck.  We need to Load an inventory text file, sort it, search it(haven't even got to that portion of the code).  I can't seem to get my insertion sort...]]></description>
			<content:encoded><![CDATA[<div>Hi all, <br />
<br />
I'm having a heck of a time with our latest assignment.  I've tried everything I can possibly think if to make this work, but with no luck.  We need to Load an inventory text file, sort it, search it(haven't even got to that portion of the code).  I can't seem to get my insertion sort to work properly.  I can get it to sort the item number, which is an int array named items.  I cannot get it to sort the corresponding item names though.  Also, for some reason when it loads the text file, it prints out the last line of the file twice.  Anyone who is willing to look at the code, I would very much appreciate it.    Thanks.<br />
<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;iomanip&gt;<br />
using namespace std;<br />
<br />
int load (char filename[], int items[], string names[], int&amp; n);<br />
int add(char filename[], int items[], string names[], int&amp; n);<br />
void sort(int items[], string names[], int n);<br />
const int SIZE = 500;<br />
int main(int argc, char *argv[])<br />
{<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; char filename[20], answer = 'n';<br />
&nbsp; &nbsp; int items[SIZE];<br />
&nbsp; &nbsp; string names[SIZE];<br />
&nbsp; &nbsp; int selection, n = 0;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Enter a filename to load: &quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; filename;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;----INVENTORY MENU----&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;1.&nbsp; Load Inventory&quot;&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;2.&nbsp; Add to Inventory&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;3.&nbsp; Search Inventory&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; selection;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  if (selection == 1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; load(filename, items, names, n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;There are &quot; &lt;&lt; n &lt;&lt; &quot; items in &quot; &lt;&lt; filename &lt;&lt; &quot;.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp;  if (selection == 2) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add(filename, items, names, n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Would you like to make another menu selection? [Y/N] &quot;;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; answer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }while(answer == 'y' || answer == 'Y');<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; return EXIT_SUCCESS;<br />
}<br />
<br />
int load(char filename[], int items[], string names[], int&amp; n) {<br />
&nbsp; &nbsp; ifstream in_stream;<br />
&nbsp; &nbsp; in_stream.open(filename);<br />
&nbsp; &nbsp; string data;<br />
&nbsp; &nbsp; n = 0;<br />
&nbsp; &nbsp; char next_symbol, number[15];<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in_stream.get(next_symbol);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; number[i] = next_symbol;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; } while (next_symbol != ' ');<br />
&nbsp; &nbsp; &nbsp; &nbsp; items[n] = atoi(number);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; getline(in_stream, data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; data &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( data != &quot;&quot;) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; names[n] = data;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl &lt;&lt; items[n];<br />
&nbsp; &nbsp; &nbsp; &nbsp;  n++;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; } while (! in_stream.eof());<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; in_stream.close();<br />
}<br />
<br />
int add(char filename[], int items[], string names[], int&amp; n){<br />
&nbsp; &nbsp; ofstream out_stream(filename, ios::app);<br />
&nbsp;  <br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Enter an item number: &quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; items[n];<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Enter an item name: &quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; names[n];<br />
&nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; &quot;Load section n is &quot; &lt;&lt; n &lt;&lt; endl;<br />
&nbsp; &nbsp; out_stream &lt;&lt; items[n] &lt;&lt; setw(15) &lt;&lt; names[n] &lt;&lt; endl;<br />
&nbsp; &nbsp; out_stream.close();<br />
&nbsp; &nbsp; sort(items, names, n);<br />
}<br />
&nbsp; &nbsp; &nbsp; <br />
void sort(int items[], string names[], int n){<br />
<br />
cout &lt;&lt; &quot;BEFORE THE SWAP&quot; &lt;&lt; endl;<br />
for (int i = 0; i &lt;n; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; items[i] &lt;&lt; setw(15) &lt;&lt; names[i]&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
int key,i;<br />
<br />
for(int j=1;j&lt;n;j++) {<br />
<br />
key=items[j];<br />
i=j-1;<br />
<br />
&nbsp; &nbsp; &nbsp; while(items[i]&gt;key &amp;&amp; i&gt;=0) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; items[i+1]=items[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; names[i+1]=names[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i--;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; items[i+1]=key;<br />
}<br />
cout &lt;&lt; &quot;AFTER THE SWAP&quot; &lt;&lt; endl;<br />
<br />
for (int i = 0; i &lt;= n; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; items[i] &lt;&lt; setw(15) &lt;&lt; names[i]&lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
return;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Jalwes</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240141.html</guid>
		</item>
		<item>
			<title>DHTMLDialog Interaction VC++ 2008</title>
			<link>http://www.daniweb.com/forums/thread240130.html</link>
			<pubDate>Sat, 21 Nov 2009 01:20:15 GMT</pubDate>
			<description><![CDATA[I built a Visual Studio 2008 VC++ project, dialog based using HTML. 
In my HTML I have: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code...]]></description>
			<content:encoded><![CDATA[<div>I built a Visual Studio 2008 VC++ project, dialog based using HTML.<br />
In my HTML I have:<br />
 <pre style="margin:20px; line-height:13px">&lt;form name=&quot;loadExcel&quot;&gt;<br />
&nbsp; &nbsp; Choose the file which contains the information:&lt;br /&gt;<br />
&nbsp; &nbsp; &lt;input type=&quot;file&quot; name=&quot;myFile&quot; value=&quot;Search&quot; id=&quot;myFileInput&quot; /&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &lt;input type=&quot;button&quot; class=&quot;Upload&quot; name=&quot;loadExcel&quot; title=&quot;Import&quot; id=&quot;loadExcelButton&quot; /&gt;<br />
&lt;/form&gt;</pre><br />
The user is supposed to browse to a valid Excel file which I will work using the excellent <span style="font-weight:bold">ExcelFormat library by Martin Fuchs</span> to produce a XML output.<br />
So, I try to capture the path to the file or at least something using the button loadExcel that will trigger a function:<br />
 <pre style="margin:20px; line-height:13px">BEGIN_DHTML_EVENT_MAP(CGeneraliDMDlg)<br />
&nbsp; &nbsp; &nbsp; &nbsp; DHTML_EVENT_ONCLICK(_T(&quot;ButtonOK&quot;), OnButtonOK)<br />
&nbsp; &nbsp; &nbsp; &nbsp; DHTML_EVENT_ONCLICK(_T(&quot;ButtonCancel&quot;), OnButtonCancel)<br />
&nbsp; &nbsp; &nbsp; &nbsp; DHTML_EVENT_ONCLICK(_T(&quot;loadExcelButton&quot;), OnLoadExcel)<br />
END_DHTML_EVENT_MAP()</pre><br />
And here is the code to my function so far:<br />
 <pre style="margin:20px; line-height:13px">HRESULT CGeneraliDMDlg::OnLoadExcel(IHTMLElement* pElement){<br />
&nbsp; &nbsp; &nbsp; &nbsp; BSTR bstrText = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; GetElement(_T(&quot;myFileInput&quot;), &amp;pElement);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(pElement){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pElement-&gt;get_innerText(&amp;bstrText);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *Text = _com_util::ConvertBSTRToString(bstrText);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AfxMessageBox(Text);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return S_OK;<br />
}</pre><br />
For some reason I don't understand, the Message box is empty, does it mean I'm not capturing anything? can someone give me a little help with this?<br />
To tell the truth, I found the code for the OnLoadExcel function doing some research, but it does not work.<br />
If I do something like  <pre style="margin:20px; line-height:13px">pElement-&gt;put_outerHTML(blah)</pre>, it works perfect, so i think somehow i'm loosing my information in the way.<br />
<br />
In advance, thanks for any help you can give me :D</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Tales</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240130.html</guid>
		</item>
		<item>
			<title>getline with for a string with two letters?</title>
			<link>http://www.daniweb.com/forums/thread240124.html</link>
			<pubDate>Sat, 21 Nov 2009 00:37:07 GMT</pubDate>
			<description><![CDATA[Hello all, 
I'm trying to parse a file, but for some reason, getline is combining my two letter words with other words. 
 
Here is the portion of code I'm working with: *note*: my program will always ignore the first word in a line 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hello all,<br />
I'm trying to parse a file, but for some reason, getline is combining my two letter words with other words.<br />
<br />
Here is the portion of code I'm working with: <span style="font-weight:bold">note</span>: my program will always ignore the first word in a line<br />
 <pre style="margin:20px; line-height:13px">char line[256];<br />
string word;&nbsp; <br />
char *line2=new char(); <br />
&nbsp; &nbsp; &nbsp; &nbsp; fgets(line, 256, in); //get the line from the in stream (which contains the file)<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (feof(in))<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%s&quot;,line); //print first line<br />
&nbsp; &nbsp; &nbsp; &nbsp; strncpy(line2,line,(strlen(line)-1)); //copy the line into a char pointer, minus the newline char<br />
&nbsp; &nbsp; &nbsp; &nbsp; string str;<br />
str.assign(line2); //copy the line2 char* into a string, this maybe be redundent<br />
<br />
stringstream s(str); //set s as a sstream reading from the str<br />
getline(s, word, ' '); //gets the first word, which I do not use<br />
while (getline(s, word, ' ')){ //gets the following words in the line in order and parses<br />
cout&lt;&lt;&quot;word is &quot; &lt;&lt; word &lt;&lt; endl;<br />
<br />
//pseudo code here where if the current parsed word is recognized, then the program prints something, otherwise it will recurse to the next line, not really important here<br />
}</pre><br />
For example, say in my file I have<br />
pet CAT AB<br />
<br />
When I use my cout to check my parsed words, I would see CAT, then ABCAT. Any reason why? Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Deadmon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240124.html</guid>
		</item>
		<item>
			<title><![CDATA[Not sure if my "for" statment code is correct.....]]></title>
			<link>http://www.daniweb.com/forums/thread240115.html</link>
			<pubDate>Fri, 20 Nov 2009 23:23:33 GMT</pubDate>
			<description><![CDATA[My question: 
What is the output of the code corresponding to the following pseudocode?  
 
 
Set y = 0 
For (i = 0; i<=6; i=i+3) 
For (j = 0; j<=15; j=j+5) 
Set y = y + 1; 
End For (j) 
End For (i)]]></description>
			<content:encoded><![CDATA[<div>My question:<br />
What is the output of the code corresponding to the following pseudocode? <br />
<br />
 <pre style="margin:20px; line-height:13px">Set y = 0<br />
For (i = 0; i&lt;=6; i=i+3)<br />
For (j = 0; j&lt;=15; j=j+5)<br />
Set y = y + 1;<br />
End For (j)<br />
End For (i)<br />
Output y</pre><br />
This is what I have so far but I'm not sure if it's right/complete:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
int main()<br />
{<br />
int y = 0;<br />
for(int i = 0; i &lt;= 6; i+= 3)<br />
for(int j = 0; j&lt;= 15; j+=5)<br />
++y;<br />
<br />
std::cout &lt;&lt; y &lt;&lt; &quot;\n&quot;;<br />
}</pre><br />
Thanks in advance!!!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>confusedndazed</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240115.html</guid>
		</item>
		<item>
			<title>Bubble and Selection sort</title>
			<link>http://www.daniweb.com/forums/thread240114.html</link>
			<pubDate>Fri, 20 Nov 2009 23:08:56 GMT</pubDate>
			<description><![CDATA[here is my codes  
basicallysorting works  
but now i have to set a counter to display out the  contents of array1 and array2 each pass of the sort. the problem is where to put that counter???? 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>here is my codes <br />
basicallysorting works <br />
but now i have to set a counter to display out the  contents of array1 and array2 each pass of the sort. the problem is where to put that counter????<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
<br />
using namespace std;<br />
// Function prototypes<br />
void showArray1(int [], int);<br />
void bubbleSortArray1(int [], int);<br />
void showArray2(int [], int);<br />
void selectionSortArray2(int [], int);<br />
<br />
&nbsp;int main()<br />
&nbsp;{<br />
&nbsp;const int SIZE = 8;&nbsp; //size of the arrays<br />
&nbsp;//two identical arrays of 8 integers <br />
&nbsp;<br />
&nbsp;int array1[SIZE] = {7, 2, 3, 8, 9, 1, 5, 4};<br />
&nbsp;int array2[SIZE] = {1, 5, 7, 8, 9, 3, 2, 0};&nbsp; //??<br />
&nbsp;<br />
&nbsp;//display First array<br />
&nbsp;cout &lt;&lt; &quot;The unsorted values in array1 are:\n&quot;;<br />
showArray1(array1, SIZE);<br />
&nbsp; <br />
&nbsp;//*call the function to sort array 1[ Binary sort]<br />
bubbleSortArray1(array1, SIZE);<br />
cout &lt;&lt; &quot;The Bubble sorted values of array1 are:\n&quot;;<br />
showArray1(array1, SIZE);<br />
&nbsp; <br />
&nbsp;//display second array<br />
&nbsp;cout &lt;&lt; &quot;The unsorted values in array2 are:\n&quot;;<br />
<br />
&nbsp;showArray2(array2, SIZE);<br />
&nbsp;<br />
//call the function to selection sort array2 in ascending order<br />
&nbsp;<br />
selectionSortArray2(array2, SIZE);<br />
cout &lt;&lt; &quot;The Selection sorted values of array2 are:\n&quot;;<br />
<br />
showArray2(array2, SIZE);<br />
<br />
&nbsp;cout &lt;&lt; &quot;End of Program.\n&quot;;<br />
&nbsp;  system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
/**********Function to display array1***************/<br />
void showArray1(int array1[], int elems)<br />
{<br />
for (int count = 0; count &lt; elems; count++)<br />
cout &lt;&lt; array1[count] &lt;&lt; &quot; &quot;;<br />
cout &lt;&lt; endl;<br />
}<br />
&nbsp; /**********Function to display array2***************/<br />
void showArray2(int array2[], int elems)<br />
{<br />
&nbsp; &nbsp;  for (int count = 0; count &lt; elems; count++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; array2[count] &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
}<br />
//**********Function to BUBBLE sort array1***************/<br />
//***********Modified to print elements position after each pass*****/<br />
/***********************************************************<br />
This function performs an ascending-order bubble sort on *<br />
&nbsp;array1. The parameter elems holds the number of elements *<br />
in the array. *<br />
***********************************************************/<br />
void bubbleSortArray1(int array[], int elems)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool swap;<br />
&nbsp; &nbsp;  do<br />
&nbsp; &nbsp;  { swap = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int count = 0; count &lt; (elems - 1); count++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (array[count] &gt; array[count + 1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = array[count];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array[count] = array[count + 1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array[count + 1] = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; swap = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  } while (swap);<br />
} <br />
//**********Function to selection sort array2***************/<br />
//***********Modified to print elements position after each pass*****/<br />
void selectionSortArray2(int array[], int elems)<br />
{<br />
&nbsp; &nbsp;  int startScan, minIndex, minValue;<br />
<br />
&nbsp; &nbsp; &nbsp; for (startScan = 0; startScan &lt; (elems - 1); startScan++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minIndex = startScan;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minValue = array[startScan];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (int index = startScan + 1; index &lt; elems; index++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (array[index] &lt; minValue)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  minValue = array[index];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  minIndex = index;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array[minIndex] = array[startScan];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array[startScan] = minValue;<br />
&nbsp; &nbsp; &nbsp;  }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>rafta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240114.html</guid>
		</item>
		<item>
			<title>structs and functions</title>
			<link>http://www.daniweb.com/forums/thread240111.html</link>
			<pubDate>Fri, 20 Nov 2009 22:34:43 GMT</pubDate>
			<description>I am working on some homework right now and the program has to return two specified values depending on the key value the user enters. I only had to write the bottom portion of the program as the top portion was given to me as a shell.  
 
It runs but is not returning the correct values, can anyone...</description>
			<content:encoded><![CDATA[<div>I am working on some homework right now and the program has to return two specified values depending on the key value the user enters. I only had to write the bottom portion of the program as the top portion was given to me as a shell. <br />
<br />
It runs but is not returning the correct values, can anyone give me any insight as to why it is not returning the correct vaues? I am not sure if I am understanding completely how structs pass values and such...<br />
<br />
Thanks<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream.h&gt;<br />
<br />
// Definition of the PhoneTones struct<br />
<br />
struct PhoneTones<br />
{<br />
&nbsp;  int rowTone,&nbsp;  // Frequencies of the tones generated by a key press<br />
&nbsp; &nbsp; &nbsp;  colTone;<br />
};<br />
<br />
// Function prototype<br />
<br />
PhoneTones keyToTones ( char key );<br />
<br />
//--------------------------------------------------------------------<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; char inputKey;&nbsp; &nbsp; &nbsp; &nbsp;  // Input key<br />
&nbsp; &nbsp; PhoneTones keyFreqs;&nbsp;  // Frequencies of the corresponding tones<br />
<br />
&nbsp; &nbsp; // Read in a series of keys and output the corresponding tones.<br />
<br />
&nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; &quot;Enter key pressed (0-9, *, or #): &quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; inputKey;<br />
&nbsp; &nbsp; keyFreqs = keyToTones(inputKey);<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Tones produced at &quot; &lt;&lt; keyFreqs.rowTone &lt;&lt; &quot; and &quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; keyFreqs.colTone &lt;&lt; &quot; Hz&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
//--------------------------------------------------------------------<br />
// Insert your keyToTones function here.<br />
//--------------------------------------------------------------------<br />
<br />
PhoneTones keyToTones ( char key )<br />
{<br />
&nbsp; &nbsp; PhoneTones Freqs;<br />
<br />
&nbsp; &nbsp; switch (key)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; case '1': case '2': case '3': Freqs.rowTone = 697; break;<br />
&nbsp; &nbsp; &nbsp; case '4': case '5': case '6': Freqs.rowTone = 770; break;<br />
&nbsp; &nbsp; &nbsp; case '7': case '8': case '9': Freqs.rowTone = 852; break;<br />
&nbsp; &nbsp; &nbsp; case '*': case '0': case '#': Freqs.rowTone = 941; break;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; switch (key)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; case '1': case '4': case '7': case '*': Freqs.colTone = 1209; break;<br />
&nbsp; &nbsp; case '2': case '5': case '8': case '0': Freqs.colTone = 1336; break;<br />
&nbsp; &nbsp; case '3': case '6': case '9': case '#': Freqs.colTone = 1477; break;<br />
&nbsp; &nbsp; }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>plobby</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240111.html</guid>
		</item>
		<item>
			<title>Inheritance</title>
			<link>http://www.daniweb.com/forums/thread240094.html</link>
			<pubDate>Fri, 20 Nov 2009 21:13:08 GMT</pubDate>
			<description><![CDATA[Okay where should I begin....  I have this rather asinine program that as of right now only asks the user what quantity of dollars and particular coins they have then just spits out what was imputed. I need to add in a 'child' class that does all the following 
 
-Add a new private or protected...]]></description>
			<content:encoded><![CDATA[<div>Okay where should I begin....  I have this rather asinine program that as of right now only asks the user what quantity of dollars and particular coins they have then just spits out what was imputed. I need to add in a 'child' class that does all the following<br />
<br />
-Add a new private or protected data member for a cents. This should be a floating point variable.<br />
<br />
-Add the appropriate accessor and mutator methods to the class<br />
<br />
-It needs to have its own no argument constructor that calls the base class constructor and then initializes cents to 0. <br />
<br />
-The new class should override the inputInfo method of Money. This new method will use the base class method to retrieve the data from the user as dollars, quarters, dimes, nickels and pennies. After the data has been retrieved the method should convert and store the value of the dollars, quarters, dimes, nickels and pennies as a floating point value in cents.<br />
<br />
-The new class should override the outputInfo method so that in additional to calling the base classes method, it prints an additional line showing the amount of money as a decimal value. <br />
<br />
I attached a UML (i think)<br />
<br />
And heres the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
class Money<br />
{<br />
private:<br />
// Private data members<br />
int dollars, quarters, dimes, nickels, pennies;<br />
public:<br />
// Default constructor<br />
Money() : dollars(0),quarters(0),dimes(0),nickels(0),pennies(0)<br />
{}<br />
// User input/output methods<br />
void inputInfo();<br />
void outputInfo();<br />
// Accessor methods<br />
int getDollars() { return(dollars); }<br />
int getQuarters() { return(quarters); }<br />
int getDimes() { return(dimes); }<br />
int getNickels() { return(nickels); }<br />
int getPennies() { return(pennies); }<br />
// Mutator methods<br />
void setDollars(int data) { dollars = data; }<br />
void setQuarters(int data) { quarters = data; }<br />
void setDimes(int data) { dimes = data; }<br />
void setNickels(int data) { nickels = data; }<br />
void setPennies(int data) { pennies = data; }<br />
};<br />
int main()<br />
{<br />
Money money;<br />
money.inputInfo ();<br />
money.outputInfo ();<br />
return 0;<br />
}<br />
void Money::outputInfo()<br />
{<br />
cout &lt;&lt; &quot;\n\nYou have &quot; &lt;&lt; getDollars() &lt;&lt; &quot; dollars, &quot;<br />
&lt;&lt; getQuarters() &lt;&lt; &quot; quarters, &quot;<br />
&lt;&lt; getDimes() &lt;&lt; &quot; dimes, &quot; &lt;&lt; getNickels()<br />
&lt;&lt; &quot; nickels and &quot; &lt;&lt; getPennies()<br />
&lt;&lt; &quot; pennies.\n&quot;;<br />
}<br />
void Money::inputInfo()<br />
{<br />
int input;<br />
cout &lt;&lt; &quot;Enter the number of dollars you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setDollars(input);<br />
cout &lt;&lt; &quot;Enter the number of quarters you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setQuarters(input);<br />
cout &lt;&lt; &quot;Enter the number of dimes you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setDimes(input);<br />
cout &lt;&lt; &quot;Enter the number of nickels you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setNickels(input);<br />
cout &lt;&lt; &quot;Enter the number of pennies you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setPennies(input);<br />
}</pre><br />
Now what I need is some help as to how to implement this new derived class into my code.<br />
<br />
And please try to keep any explanations simple I am rather &quot;challenged&quot; in this field.</div>  <br /> <div style="padding:5px">    <fieldset class="fieldset"> <legend>Attached Images</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/png.gif" alt="File Type: png" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12658&amp;d=1258751196" target="_blank">UML.png</a> (61.1 KB)</td> </tr> </table> </fieldset>   </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>itzaaron</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240094.html</guid>
		</item>
		<item>
			<title><![CDATA[separating left & right channels in array using libsndfile]]></title>
			<link>http://www.daniweb.com/forums/thread240084.html</link>
			<pubDate>Fri, 20 Nov 2009 20:48:10 GMT</pubDate>
			<description><![CDATA[Hi- 
 
I'm really new to c+ (this is day two) and I'm trying to write a program that will allow me to write audio data from a wave file into two arrays for the left channel and the right channel, i've pieced together this code so far and its definitely grabbing something from the wave file however...]]></description>
			<content:encoded><![CDATA[<div>Hi-<br />
<br />
I'm really new to c+ (this is day two) and I'm trying to write a program that will allow me to write audio data from a wave file into two arrays for the left channel and the right channel, i've pieced together this code so far and its definitely grabbing something from the wave file however i've no idea if its writing out left or right data or even a combination of the two.<br />
<br />
any ideas what I could be doing wrong?<br />
<br />
thanks<br />
<br />
domm<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">int ReadWave::waveFileToArray(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //sndfile obj + soundfile info object<br />
&nbsp; &nbsp; &nbsp; &nbsp; SNDFILE *sf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  SF_INFO info;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  int num;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int num_items;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numFrames;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int sampleRate;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int channels;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  FILE *out;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; SNDFILE *outWave;<br />
&nbsp; &nbsp; &nbsp; &nbsp; // open the wave<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; info.format = 0;<br />
&nbsp;  sf = sf_open(filePath, SFM_READ,&amp;info);<br />
&nbsp;  if (sf == NULL)<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;Failed to open the file.\n&quot;);<br />
&nbsp; &nbsp; &nbsp;  exit(-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; numFrames = info.frames;<br />
&nbsp;  sampleRate = info.samplerate;<br />
&nbsp;  channels = info.channels;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; num_items = numFrames * channels;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector &lt;int&gt; buffer(num_items);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; num = sf_read_int(sf, &amp;buffer[0], num_items);<br />
&nbsp; &nbsp; &nbsp; &nbsp; sf_close(sf);<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; num; i += channels){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rawWaveDataArray.push_back(buffer[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;the array size is: %d \n&quot;, rawWaveDataArray.size());<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  printf(&quot;frames=%d\n&quot;, numFrames);<br />
&nbsp;  printf(&quot;samplerate=%d\n&quot;, sampleRate);<br />
&nbsp;  printf(&quot;channels=%d\n&quot;,channels);<br />
<br />
&nbsp;  printf(&quot;num_items=%d\n&quot;,num_items);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Read %d items\n&quot;, num);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; rawWaveDataArray.size(); i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\n&quot;, rawWaveDataArray[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp;  fclose(out);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>debugdom</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240084.html</guid>
		</item>
		<item>
			<title>simulating alt+2 (keypad) combination</title>
			<link>http://www.daniweb.com/forums/thread240082.html</link>
			<pubDate>Fri, 20 Nov 2009 20:47:06 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". 
 
keybd_event(VK_MENU,0 ,0 , 0); //Alt Press 
 
Sleep(10);...]]></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 />
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);<br />
<br />
Neither does this work. Again, just prints &quot;2&quot;.<br />
<br />
        INPUT inputs = {0}; <br />
	inputs.type = INPUT_KEYBOARD; <br />
<br />
	KEYBDINPUT ki = {0}; <br />
	ki.wVk = VK_LMENU;<br />
<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt<br />
<br />
	ki.wVk = VK_NUMPAD2;<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
	ki.dwFlags = KEYEVENTF_KEYUP;<br />
<br />
	ki.wVk = VK_NUMPAD2;<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
	ki.wVk = VK_LMENU;<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kangekraam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240082.html</guid>
		</item>
		<item>
			<title>about this function..</title>
			<link>http://www.daniweb.com/forums/thread240081.html</link>
			<pubDate>Fri, 20 Nov 2009 20:33:24 GMT</pubDate>
			<description><![CDATA[I just want to know what does the below mentioned function means? 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>I just want to know what does the below mentioned function means?<br />
<br />
 <pre style="margin:20px; line-height:13px"><span style="color:Green">void swap(char&amp; a, char&amp; b)</span></pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240081.html</guid>
		</item>
		<item>
			<title>Create vector of strings with alphabet</title>
			<link>http://www.daniweb.com/forums/thread240078.html</link>
			<pubDate>Fri, 20 Nov 2009 20:12:47 GMT</pubDate>
			<description><![CDATA[So here is the question and it is really stumping me because I can print the alphabet once but cant figure out how to repeat it. 
 
First create a character array that contains the 26 letters as shown here. //Easy I can copy and paste ha. 
 
	  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>So here is the question and it is really stumping me because I can print the alphabet once but cant figure out how to repeat it.<br />
<br />
First create a character array that contains the 26 letters as shown here. //Easy I can copy and paste ha.<br />
<br />
	 <pre style="margin:20px; line-height:13px">char cAlphabet[] = {'a','b','c','d','e','f',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'g','h','i','j','k','l','m','n','o','p',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'q','r','s','t','u','v','w','x','y','z'};</pre><br />
Then create a vector of strings where the first string is 'a' and the second is 'bc', the third, 'def', etc. Create the number of strings requested by the user. Once you reach the letter z, start again with first letter in the alphabet. When you are done, print each vector to the screen.<br />
<br />
How many strings would you like to create?<br />
8<br />
<br />
a<br />
bc<br />
def<br />
ghij<br />
klmno<br />
pqrstu<br />
vwxyzab<br />
cdefghij<br />
<br />
<br />
<br />
Here is what I have so far it works up until 6 or 7 strings but I dont know how to fix it so that it will continue to print strings with the alphabet starting over. Anything helps, Thanks.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
<br />
void printVector( vector&lt;string&gt; v )<br />
{<br />
&nbsp; for(unsigned int i = 0; i &lt; v.size(); i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; cout &lt;&lt; v[i] &lt;&lt; &quot;\t&quot;;<br />
&nbsp; }<br />
&nbsp; cout &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
}<br />
<br />
int main()<br />
{<br />
int nStrings=0;<br />
<br />
string str1=&quot; &quot;;<br />
<br />
vector&lt;string&gt; myVector;<br />
<br />
char cAlphabet[] = {'a','b','c','d','e','f',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'g','h','i','j','k','l','m','n','o','p',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'q','r','s','t','u','v','w','x','y','z'};<br />
<br />
str1=cAlphabet;<br />
string str=&quot; &quot;;<br />
str= str1.substr(0,26);<br />
cout&lt;&lt;str&lt;&lt;endl;<br />
<br />
cout&lt;&lt;&quot;How many strings would you like?&quot;&lt;&lt;endl;<br />
cin&gt;&gt;nStrings;<br />
<br />
for(int i=0; i &lt; nStrings; i++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; static int j=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; j= j + i;<br />
<br />
myVector.push_back(str.substr( j, (i+1) ));<br />
<br />
printVector(myVector);<br />
myVector.clear();<br />
<br />
}<br />
<br />
<br />
return 1;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>wh33lz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240078.html</guid>
		</item>
		<item>
			<title><![CDATA[[][] operator?]]></title>
			<link>http://www.daniweb.com/forums/thread240070.html</link>
			<pubDate>Fri, 20 Nov 2009 19:27:27 GMT</pubDate>
			<description><![CDATA[Say you have a class that has members 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a>...]]></description>
			<content:encoded><![CDATA[<div>Say you have a class that has members<br />
 <pre style="margin:20px; line-height:13px">private:<br />
double a,b,c,d,e,f,g,h,i;</pre><br />
You can make an accessor like:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; double operator[](int index)<br />
&nbsp; {<br />
&nbsp; &nbsp; if(index == 0)<br />
&nbsp; &nbsp; &nbsp; return a;<br />
&nbsp; &nbsp; else if(index == 1)<br />
&nbsp; &nbsp; &nbsp; return b;<br />
&nbsp; &nbsp; else if(index == 2)<br />
&nbsp; &nbsp; &nbsp; return c;<br />
&nbsp; }</pre><br />
But how would you do something like this:<br />
 <pre style="margin:20px; line-height:13px"> <br />
&nbsp; double operator[][](int rindex, int cindex)<br />
&nbsp; {<br />
&nbsp; &nbsp; if(rindex == 0 &amp;&amp; cindex == 0)<br />
&nbsp; &nbsp; &nbsp; return a;<br />
&nbsp; &nbsp; else if(rindex == 1 &amp;&amp; cindex == 0)<br />
&nbsp; &nbsp; &nbsp; return b;<br />
&nbsp; &nbsp; else if(rindex == 2 &amp;&amp; cindex == 0)<br />
&nbsp; &nbsp; &nbsp; return c;<br />
&nbsp; &nbsp; else if(rindex == 0 &amp;&amp; cindex == 1)<br />
&nbsp; &nbsp;  return d;<br />
..... etc ...<br />
&nbsp; }</pre><br />
The compiler doesn't like the above attempt. The behavior I'm looking for is:<br />
 <pre style="margin:20px; line-height:13px">MatrixClass Matrix;<br />
// ... fill it<br />
double test = Matrix[0][1];</pre><br />
Thoughts?<br />
<br />
Thanks,<br />
<br />
Dave</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>daviddoria</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240070.html</guid>
		</item>
		<item>
			<title>Algoritm Question</title>
			<link>http://www.daniweb.com/forums/thread240060.html</link>
			<pubDate>Fri, 20 Nov 2009 18:19:47 GMT</pubDate>
			<description><![CDATA[Hello there, 
 
I have the following situation : I have a moving ball in a rectangular 2D chamber. When the ball touches the walls of the chamber it changes it's direction. It is simple to implement the ball movement when the chamber is empty ( it has only 4 walls). My question is , how to I...]]></description>
			<content:encoded><![CDATA[<div>Hello there,<br />
<br />
I have the following situation : I have a moving ball in a rectangular 2D chamber. When the ball touches the walls of the chamber it changes it's direction. It is simple to implement the ball movement when the chamber is empty ( it has only 4 walls). My question is , how to I implement the movement of the ball in a chamber with numerous objects in it ? ( by objects I refer to rectangular or square shapes). Also , I know the initial ball direction. I've tried using a matrix to map the room, but I got stuck in it. Have any good ides of how could this be done ?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>spiriad</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240060.html</guid>
		</item>
		<item>
			<title>program does not read input</title>
			<link>http://www.daniweb.com/forums/thread240058.html</link>
			<pubDate>Fri, 20 Nov 2009 18:15:17 GMT</pubDate>
			<description>Hello all, 
 
I did this program below, it is meant to get a student name then 5 of his/her grades sums them up in a void function and calculate the average but outputs the average from the main  
 
the problem is that the loop goes on and prints the prompt but takes no input  
 
how can I fix that...</description>
			<content:encoded><![CDATA[<div>Hello all,<br />
<br />
I did this program below, it is meant to get a student name then 5 of his/her grades sums them up in a void function and calculate the average but outputs the average from the main <br />
<br />
the problem is that the loop goes on and prints the prompt but takes no input <br />
<br />
how can I fix that ?<br />
<br />
 <pre style="margin:20px; line-height:13px"># include &lt;iostream&gt;<br />
# include &lt;string&gt;<br />
using namespace std;<br />
<br />
void avg (int grade[]);<br />
<br />
int main()<br />
{<br />
&nbsp; char name;<br />
&nbsp; double average;<br />
&nbsp; int grade[5];<br />
<br />
&nbsp; cout &lt;&lt; &quot;Student name&quot; &lt;&lt;endl;<br />
&nbsp; cin.get(name);<br />
&nbsp; cout &lt;&lt;endl;<br />
<br />
&nbsp; avg (grade);<br />
&nbsp; cout &lt;&lt; &quot;The average is &quot; &lt;&lt; average &lt;&lt;endl;<br />
<br />
&nbsp;return 0;<br />
}<br />
<br />
&nbsp; void avg (int grade[])<br />
&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double sum=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double average;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;5; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter grade&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; grade[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum= sum+grade[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; average = sum/5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>new programer</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240058.html</guid>
		</item>
		<item>
			<title>store numbers from a .txt file</title>
			<link>http://www.daniweb.com/forums/thread240034.html</link>
			<pubDate>Fri, 20 Nov 2009 15:15:38 GMT</pubDate>
			<description><![CDATA[Hi, I've just started with c++ and I have no clue how to do this. Right now I have a code that just printing out the text lines in my file and how many lines there is just to check that i can read from my file... 
 
But what I want to do and can't figure out is to pick out and store numbers from...]]></description>
			<content:encoded><![CDATA[<div>Hi, I've just started with c++ and I have no clue how to do this. Right now I have a code that just printing out the text lines in my file and how many lines there is just to check that i can read from my file...<br />
<br />
But what I want to do and can't figure out is to pick out and store numbers from text lines. <br />
<br />
Consider this as user inputs to a file:<br />
<br />
Number 10 Downing Street<br />
My birthday is 6 May 1980<br />
<br />
And now I want to read from the .txt file and store the number 10 from the first text line and then store 6 and 1980 from the second line of text. <br />
<br />
 <pre style="margin:20px; line-height:13px">//..Some codes to put in lines of user specific text to a file. [done]<br />
<br />
//And now the code that outputs the text rows and number of rows in<br />
//the file but have nothing to do with what i want to achive :(<br />
&nbsp; <br />
&nbsp; ifstream inputfile(filename);<br />
&nbsp; char text;<br />
&nbsp; int n = 0; <br />
&nbsp; <br />
&nbsp; while (inputfile.get(text))<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; cout.put(text);<br />
&nbsp; &nbsp; &nbsp; if (text == '\n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; ++n;<br />
&nbsp; &nbsp; }<br />
&nbsp; <br />
&nbsp; cout &lt;&lt; endl &lt;&lt; There is &quot; &lt;&lt; n &lt;&lt; &quot; rows of text&quot;;</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nunchuckie</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240034.html</guid>
		</item>
		<item>
			<title>Problems with compiling in VS10 Express Beta2</title>
			<link>http://www.daniweb.com/forums/thread240032.html</link>
			<pubDate>Fri, 20 Nov 2009 14:58:47 GMT</pubDate>
			<description>I decided to try Visual Studio 2010 express Beta 2. 
This code works fine on my other computer that uses Visual Studio 2009 Pro. 
 
I am going to make a Timer that count down from a fixed time depending on foodsource. But first this code need to work :P so I can add the rest :) I wish to get this...</description>
			<content:encoded><![CDATA[<div>I decided to try Visual Studio 2010 express Beta 2.<br />
This code works fine on my other computer that uses Visual Studio 2009 Pro.<br />
<br />
I am going to make a Timer that count down from a fixed time depending on foodsource. But first this code need to work :P so I can add the rest :) I wish to get this working in VS10E because I dont use VS08 on this computer.<br />
 <pre style="margin:20px; line-height:13px">#include &lt;Windows.h&gt;<br />
<br />
const char gClassName[] = &quot;TibiaTimer&quot;;<br />
<br />
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(msg)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case WM_CLOSE:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DestroyWindow(hwnd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case WM_DESTROY:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostQuitMessage(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; default:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return DefWindowProc(hwnd, msg, wParam, lParam);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; WNDCLASSEX wc;<br />
&nbsp; &nbsp; &nbsp; &nbsp; HWND hwnd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; MSG msg;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.cbSize&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = sizeof(WNDCLASSEX);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.style&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.lpfnWndProc&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = WndProc;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.cbClsExtra&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.cbWndExtra&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hInstance&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = hInstance;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hIcon&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = LoadIcon(NULL, IDI_APPLICATION);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hIconSm&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = LoadIcon(NULL, IDI_APPLICATION);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hCursor&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = LoadCursor(NULL, IDC_ARROW);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hbrBackground&nbsp; &nbsp; &nbsp; &nbsp; = (HBRUSH)(COLOR_WINDOW+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.lpszMenuName&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.lpszClassName&nbsp; &nbsp; &nbsp; &nbsp; = &quot;TibiaTimer&quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!RegisterClassEx(&amp;wc))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBoxA(NULL, &quot;Window registration failed!&quot;, &quot;FATAL ERROR&quot;, MB_ICONEXCLAMATION | MB_OK);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, &quot;TibiaTimer&quot;, &quot;TibiaTimer&quot;, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 340, 240, NULL, NULL, hInstance, NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(hwnd == NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBoxA(NULL, &quot;Window creation failed!&quot;, &quot;FATAL ERROR&quot;, MB_ICONEXCLAMATION | MB_OK);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(hwnd, nCmdShow);<br />
&nbsp; &nbsp; &nbsp; &nbsp; UpdateWindow(hwnd);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(GetMessage(&amp;msg, NULL, 0, 0) &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TranslateMessage(&amp;msg);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DispatchMessage(&amp;msg);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return msg.wParam;<br />
}</pre><br />
I use char-set <span style="font-weight:bold">Use Multi-Byte Character Set</span> and have tried Unicode as well but then I get some compiler errors. But I get a lot of Linker errors in VS10E. Here is the list for anyone that wanna take a look and maybe shed some light on this.<br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  ------ Build started: Project: TibiaTimer, Configuration: Debug Win32 ------<br />
  main.cpp<br />
main.obj : error LNK2028: unresolved token (0A000020) &quot;extern &quot;C&quot; int __stdcall DestroyWindow(struct HWND__ *)&quot; (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2028: unresolved token (0A000022) &quot;extern &quot;C&quot; int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function &quot;extern &quot;C&quot; int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z)<br />
main.obj : error LNK2028: unresolved token (0A000029) &quot;extern &quot;C&quot; unsigned short __stdcall RegisterClassExA(struct tagWNDCLASSEXA const *)&quot; (?RegisterClassExA@@$$J14YGGPBUtagWNDCLASSEXA@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A00002B) &quot;extern &quot;C&quot; void __stdcall PostQuitMessage(int)&quot; (?PostQuitMessage@@$$J14YGXH@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2028: unresolved token (0A000035) &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)&quot; (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A00003E) &quot;extern &quot;C&quot; int __stdcall TranslateMessage(struct tagMSG const *)&quot; (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000043) &quot;extern &quot;C&quot; int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)&quot; (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000046) &quot;extern &quot;C&quot; struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)&quot; (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000048) &quot;extern &quot;C&quot; long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2028: unresolved token (0A00004C) &quot;extern &quot;C&quot; int __stdcall ShowWindow(struct HWND__ *,int)&quot; (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000050) &quot;extern &quot;C&quot; long __stdcall DispatchMessageA(struct tagMSG const *)&quot; (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; long __cdecl DispatchMessage(struct tagMSG const *)&quot; (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z)<br />
main.obj : error LNK2028: unresolved token (0A000055) &quot;extern &quot;C&quot; int __stdcall UpdateWindow(struct HWND__ *)&quot; (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000056) &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)&quot; (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function &quot;extern &quot;C&quot; int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; long __stdcall DispatchMessageA(struct tagMSG const *)&quot; (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; long __cdecl DispatchMessage(struct tagMSG const *)&quot; (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; void __stdcall PostQuitMessage(int)&quot; (?PostQuitMessage@@$$J14YGXH@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall DestroyWindow(struct HWND__ *)&quot; (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall TranslateMessage(struct tagMSG const *)&quot; (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall UpdateWindow(struct HWND__ *)&quot; (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall ShowWindow(struct HWND__ *,int)&quot; (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)&quot; (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)&quot; (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; unsigned short __stdcall RegisterClassExA(struct tagWNDCLASSEXA const *)&quot; (?RegisterClassExA@@$$J14YGGPBUtagWNDCLASSEXA@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)&quot; (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)&quot; (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
C:\development\TibiaTimer\TibiaTimer\Debug\TibiaTimer.exe : fatal error LNK1120: 26 unresolved externals<br />
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========  <hr /> </td> </tr> </table> </div>I wanted to attach a zip file but I wasn't allowed :P maybe the file was to big.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>FrozenSnake</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240032.html</guid>
		</item>
		<item>
			<title>Converting wav file to text format  and vice versa</title>
			<link>http://www.daniweb.com/forums/thread240025.html</link>
			<pubDate>Fri, 20 Nov 2009 14:36:35 GMT</pubDate>
			<description>Hey all  
 
I need to convert audio file of wav format into text file in order to feed it as input to an encryption algorithm(IBE encrypt method of Miracl (http://www.shamus.ie/) library takes only texts as input) and have to reconvert the decrypted text file to audio format. 
 
Could you please...</description>
			<content:encoded><![CDATA[<div>Hey all <br />
<br />
I need to convert audio file of wav format into text file in order to feed it as input to an encryption algorithm(IBE encrypt method of <a rel="nofollow" class="t" href="http://www.shamus.ie/" target="_blank">Miracl</a> library takes only texts as input) and have to reconvert the decrypted text file to audio format.<br />
<br />
Could you please suggest me a way to accomplish this. I have rest of my code written in C++.<br />
<br />
regards <br />
bk</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bkpally263</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240025.html</guid>
		</item>
		<item>
			<title>code tags....</title>
			<link>http://www.daniweb.com/forums/thread240024.html</link>
			<pubDate>Fri, 20 Nov 2009 14:28:36 GMT</pubDate>
			<description><![CDATA[I wonder if anyone can tell me how the code tags works? As per my understanding does it works like:   <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help...]]></description>
			<content:encoded><![CDATA[<div>I wonder if anyone can tell me how the code tags works? As per my understanding does it works like:  <pre style="margin:20px; line-height:13px">MY CODE HERE.....</pre> for the enitre block of code? or I need to do this for every line of code?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240024.html</guid>
		</item>
		<item>
			<title>Help In Structures !!!</title>
			<link>http://www.daniweb.com/forums/thread240015.html</link>
			<pubDate>Fri, 20 Nov 2009 13:41:29 GMT</pubDate>
			<description><![CDATA[Hello All ,This is me again :icon_mrgreen: 
 
I'm Making a programme which tell the user to input the name 
of the product he wants to show its Price and Amount ,but i have a problem: 
 
Here's The Code 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hello All ,This is me again :icon_mrgreen:<br />
<br />
I'm Making a programme which tell the user to input the name<br />
of the product he wants to show its Price and Amount ,but i have a problem:<br />
<br />
Here's The Code<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;conio.h&gt;<br />
using namespace std;<br />
<br />
struct Shop<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int Price;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int Amount;<br />
};<br />
<br />
void PrintPrice (Shop Product);<br />
void PrintAmount (Shop Product);<br />
<br />
int main()<br />
{<br />
//For Input:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop FI;<br />
<br />
//Products:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop Apple;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop Banana;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop Orange;<br />
<br />
//Prices:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Apple.Price = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Banana.Price = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Orange.Price = 7;<br />
<br />
//Amounts:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Apple.Amount = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Banana.Amount = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Orange.Amount = 15;<br />
<br />
//Programme:<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter The Product's Name: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; FI;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintPrice(FI);<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintAmount(FI);<br />
<br />
//End Of Programme:<br />
&nbsp; &nbsp; &nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
void PrintPrice (Shop Product)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The Price Is: &quot; &lt;&lt; Product.Price &lt;&lt;endl;<br />
}<br />
<br />
void PrintAmount (Shop Product)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The Amount Is: &quot; &lt;&lt; Product.Amount;<br />
}</pre><br />
I Know This Is Wrong:<br />
 <pre style="margin:20px; line-height:13px">cin &gt;&gt; FI;</pre>so what can it be replaced by?<br />
Hope you got it...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kim00000</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240015.html</guid>
		</item>
		<item>
			<title>Even Number Program</title>
			<link>http://www.daniweb.com/forums/thread240007.html</link>
			<pubDate>Fri, 20 Nov 2009 12:49:33 GMT</pubDate>
			<description>I wrote this program which takes the value from the user and makes it into a even number if the number entered was odd, if not then print out a message to say they need to enter a odd number. But the program continues to return a value from the makeEven function even though I just want it to print...</description>
			<content:encoded><![CDATA[<div>I wrote this program which takes the value from the user and makes it into a even number if the number entered was odd, if not then print out a message to say they need to enter a odd number. But the program continues to return a value from the makeEven function even though I just want it to print out the message saying enter an odd number.<br />
<br />
I'm relatively new to C++ and just cant get my head around where it is getting the value it happens to print out.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
int makeEven(int x)<br />
{ <br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( x % 2 != 0 ) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return x-1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Please enter an odd number!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; goto /*line*/ 18;<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter an integer: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Your number is now: &quot; &lt;&lt; makeEven(x) &lt;&lt;endl; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
};</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nedsnurb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240007.html</guid>
		</item>
		<item>
			<title>Multiple Funcs passed to text file</title>
			<link>http://www.daniweb.com/forums/thread240001.html</link>
			<pubDate>Fri, 20 Nov 2009 12:01:02 GMT</pubDate>
			<description>Hi there, 
 
I am trying to make a program, as shown below.  I have used a snippet with hello and bye as the program is really very big.  Unfortunately I am unable to edit these functions as they are all part of a complex linked list. 
 
I am trying to pass both functions from the class CWrite into...</description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
I am trying to make a program, as shown below.  I have used a snippet with hello and bye as the program is really very big.  Unfortunately I am unable to edit these functions as they are all part of a complex linked list.<br />
<br />
I am trying to pass both functions from the class CWrite into a text file however what currently occurs is the second function overwrites the first function (i think).  I have genuinly no idea what to do to solve this.<br />
<br />
Any help fixing this would be greatly appreciated. <br />
<br />
 <pre style="margin:20px; line-height:13px">#inlcude &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;sstream&gt;<br />
<br />
class CWrite<br />
{<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; int write(std::string name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int write(std::string name);<br />
};<br />
<br />
#include “stdafx.h”<br />
#include “output.h”<br />
<br />
int CWrite::write(std::string name)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::ofstream output(name.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; output&lt;&lt;”HELLO”&lt;&lt;std::endl;<br />
output.close();<br />
return 0;<br />
}<br />
<br />
int CWrite::write(std::string name)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::ofstream output(name.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; output&lt;&lt;”HELLO”&lt;&lt;std::endl;<br />
output.close();<br />
return 0;<br />
}<br />
<br />
Private: System::Void ButOut_Click(System::object^ sneder, System::eventArgs^ e)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; SaveFileDialog ^ saveFileDialog1 = gcnew SaveFileDialog();<br />
&nbsp; &nbsp; &nbsp; &nbsp; savefileDialog1-&gt;Filter = “txt files (*.txt)|*.txt|All files (*.*)|*.*”;<br />
&nbsp; &nbsp; &nbsp; &nbsp; saveFileDialog1-&gt;InitialDirectory = “library”;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(saveFileDialog1-&gt;ShowDialog() == System::Windows::Forms::DialogResult::Ok)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CWrite a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::string std_name = SystemToStdString(saveFileDialog1-&gt;FileName);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int success = a.write(std_name) + a.writeSDF(std_name);<br />
}</pre><br />
Please ignore any syntax errors as the code had to be written from Word.<br />
<br />
Thanks in advance, <br />
<br />
Andy</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ab00120</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240001.html</guid>
		</item>
		<item>
			<title>Errors in my code (using arrays)</title>
			<link>http://www.daniweb.com/forums/thread239997.html</link>
			<pubDate>Fri, 20 Nov 2009 11:26:35 GMT</pubDate>
			<description><![CDATA[Hello everyone; 
 
I did a program using arrays -for the first time- 
 
I've got errors, I fixed some and there are others left that I couldn't straighten  
 
any help is highly appreciated  
 
here is the code :]]></description>
			<content:encoded><![CDATA[<div>Hello everyone;<br />
<br />
I did a program using arrays -for the first time-<br />
<br />
I've got errors, I fixed some and there are others left that I couldn't straighten <br />
<br />
any help is highly appreciated <br />
<br />
here is the code :<br />
<br />
 <pre style="margin:20px; line-height:13px"># include &lt;iostream&gt;<br />
# include &lt;iomanip&gt;<br />
using namespace std;<br />
<br />
int read_car (int cars[], int n);<br />
double read_time (double time[], int n);<br />
double charge (time[]);<br />
void print ();<br />
<br />
double sum_time, sum_charge;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int time;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int cars[n];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int n;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Welcome to the Car Parking fee calculater.&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the numbers of the cars.&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; n;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; read_car (cars,n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; read_time(time,n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; charge(time,n);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; print ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
<br />
<br />
<br />
<br />
//1<br />
<br />
int read_car (int cars[], int n)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; cars[i];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return cars;<br />
}<br />
<br />
//2<br />
double read_time (double time[], int n)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; sum=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; time[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; time[i] = ceil(time);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; sum_time= sum + time;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return time;<br />
}<br />
//3<br />
double charge (double time[],int n)<br />
&nbsp; &nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double charge;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double sum=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ( int i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (time &lt;= 3.00)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charge= 2.00;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (time == 24.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charge = 10.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charge = (time - 3)*0.5 + 2.00;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum_charge= sum+charge;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return charge;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
//4<br />
void print (n)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; left;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(6) &lt;&lt;&quot;Car&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt;&quot;Hours&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt;&quot;Charge&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;__________________&quot;&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(6) &lt;&lt; i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; time[i]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; charge (time,n)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;__________________&quot;&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(6) &lt;&lt;&quot;Total&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; sum_time<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; sum_charge<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;endl;<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>new programer</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239997.html</guid>
		</item>
		<item>
			<title>C++ recursive function (very simple one)</title>
			<link>http://www.daniweb.com/forums/thread239964.html</link>
			<pubDate>Fri, 20 Nov 2009 08:43:52 GMT</pubDate>
			<description>How do I write a recursive function in C++ to display a triangle of * like this using a parameter size (e.g. 4 in the following example): 
 
* 
** 
*** 
**** 
 
I am able to write a recursive function to display an inverted triangle like this: 
 
****</description>
			<content:encoded><![CDATA[<div>How do I write a recursive function in C++ to display a triangle of * like this using a parameter size (e.g. 4 in the following example):<br />
<br />
*<br />
**<br />
***<br />
****<br />
<br />
I am able to write a recursive function to display an inverted triangle like this:<br />
<br />
****<br />
***<br />
**<br />
*<br />
<br />
The code for the inverted triangle function is:<br />
<br />
 <pre style="margin:20px; line-height:13px">void inverted(int a)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (a==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;*&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; for (int i=0; i&lt;a; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;*&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inverted(a-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
I am allowed to use a loop (e.g. for loop) to print a row of * but I <span style="font-style:italic">must</span> use a recursive function to control the number of rows.<br />
<br />
Please, provide some insight into the problem. I need it to work urgently but I am not able to figure out a solution.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>codeyy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239964.html</guid>
		</item>
		<item>
			<title>How To Bubble Sort</title>
			<link>http://www.daniweb.com/forums/thread239950.html</link>
			<pubDate>Fri, 20 Nov 2009 07:39:30 GMT</pubDate>
			<description>Can someone please explain the concept behind bubble sorting a vector step by step? I know this is a tedious task so whoever answers I will much appreciate it! :)  
 
Questions: 
 
1.) What variables are being used? 
2.) How and where is the function placed? 
3.) Where and why are the for loops?...</description>
			<content:encoded><![CDATA[<div>Can someone please explain the concept behind bubble sorting a vector step by step? I know this is a tedious task so whoever answers I will much appreciate it! :) <br />
<br />
Questions:<br />
<br />
1.) What variables are being used?<br />
2.) How and where is the function placed?<br />
3.) Where and why are the for loops?<br />
4.) Step by step procedure in example of vector bubble sort.<br />
<br />
THANK YOU!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>EngneerNitemare</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239950.html</guid>
		</item>
		<item>
			<title>Revrse String</title>
			<link>http://www.daniweb.com/forums/thread239942.html</link>
			<pubDate>Fri, 20 Nov 2009 06:27:12 GMT</pubDate>
			<description><![CDATA[The code below runs fine but I want some help how can I get output of my original input and reverse of that  i.e. ABCDE Z. WXYZ ---> EDCBA .Z ZYXW The below is the code for this. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>The code below runs fine but I want some help how can I get output of my original input and reverse of that  i.e. ABCDE Z. WXYZ ---&gt; EDCBA .Z ZYXW The below is the code for this.<br />
<br />
 <pre style="margin:20px; line-height:13px"> <br />
#include &lt;iostream&gt;<br />
#include &lt;cstring&gt;<br />
<br />
using namespace std;<br />
void swap(char&amp; a, char&amp; b)<br />
{<br />
&nbsp; char tmp = a;<br />
&nbsp; a = b;<br />
&nbsp; b = tmp;<br />
}<br />
int main()<br />
{<br />
&nbsp; char name[19] = &quot;ABCDE Z. WXYX&quot;;<br />
&nbsp; int a = -1, b = -1;<br />
&nbsp; int nameLength = strlen(name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (int i = 0; i &lt;= nameLength; ++i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (i == nameLength || name[i] == ' ')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  b = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (int j = 0; j &lt; (b - a) / 2; ++j)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  swap(name[j + a], name[b - j - 1]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a = b + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (a == -1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; name &lt;&lt;&quot;\n&quot;;<br />
<br />
&nbsp;  system(&quot;PAUSE&quot;);<br />
&nbsp;  return EXIT_SUCCESS;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239942.html</guid>
		</item>
		<item>
			<title>Arrays and Strings</title>
			<link>http://www.daniweb.com/forums/thread239941.html</link>
			<pubDate>Fri, 20 Nov 2009 06:26:11 GMT</pubDate>
			<description><![CDATA[I have been writing a program using arrays and strings.Here is my  question. 
A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In "tests.dat"Each record of which consists of a student id, followed by a blank, followed by...]]></description>
			<content:encoded><![CDATA[<div>I have been writing a program using arrays and strings.Here is my  question.<br />
A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In &quot;tests.dat&quot;Each record of which consists of a student id, followed by a blank, followed by students 20 responses. In &quot;answers.dat&quot; which consists of a single record, namely the correct answers to the exam.Then It needs to produce a grade summary report like this.If the answer is correct it should put a &quot;*&quot; by the correct answer<br />
<br />
<br />
student-id number correct<br />
1231231212312       12<br />
1233424325435        25<br />
....                              ..<br />
<br />
<br />
<br />
<br />
<br />
<br />
question A   B    C    D   E<br />
1            5   1    13* 3   1<br />
2            4   7*   5   12  7<br />
.<br />
.<br />
...<br />
<br />
<br />
<br />
this is what i got so far.Thank you<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;fstream&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;cstdlib&gt;<br />
<br />
using namespace std;<br />
int question[20][5];<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream fanswers, fcorrect_keys;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; char correct_keys[21];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char student_id[100][12], answers[100][21];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char id_buf[12], answers_buf[21];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int student_count = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; fcorrect_keys.open(&quot;Answers.dat&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(!fcorrect_keys.eof())&nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fcorrect_keys &gt;&gt; answers_buf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(correct_keys, answers_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
//&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; correct_keys &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; fcorrect_keys.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; fanswers.open(&quot;Tests.dat&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(!fanswers.eof())&nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fanswers &gt;&gt; id_buf &gt;&gt; answers_buf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(student_id[student_count], id_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(answers[student_count],answers_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; student_count++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
//&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; i &lt; student_count;i++)<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; student_id[i] &lt;&lt; &quot;&nbsp; &quot; &lt;&lt; answers[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fanswers.close();// close the file&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; student_id&nbsp; &nbsp; &nbsp; number_correct&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; student_count; i++)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int correct_count = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int j = 0; j &lt; 20; j++)&nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (answers [i][j] == correct_keys[j])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; correct_count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; question[j][answers[i][j] - 'A']++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%11.11s&nbsp; &nbsp; &nbsp; &nbsp;  %2d\n&quot;, student_id[i],correct_count);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;Number of students taking exam : &quot; &lt;&lt; student_count &lt;&lt; endl; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nquestion&nbsp; &nbsp;  A&nbsp; &nbsp; B&nbsp; &nbsp; C&nbsp; &nbsp; D&nbsp; &nbsp; E\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int k = 0; k &lt; 20 ; k++)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;&nbsp;  %2d&nbsp; &nbsp; &nbsp; &quot;,1+k);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int l=0;l &lt; 5; l++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; %2d%c &quot;, question[k][l], (l == (correct_keys[k] - 'A') ? '*' : ' '));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>thebeast91</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239941.html</guid>
		</item>
		<item>
			<title>DirectX 9 3D Models</title>
			<link>http://www.daniweb.com/forums/thread239938.html</link>
			<pubDate>Fri, 20 Nov 2009 06:19:44 GMT</pubDate>
			<description>How do I load 3D models that are in the .x format from DirectX 9? 
I am trying to make a simple engine and this is the part where I am stuck at.</description>
			<content:encoded><![CDATA[<div>How do I load 3D models that are in the .x format from DirectX 9?<br />
I am trying to make a simple engine and this is the part where I am stuck at.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>tomtetlaw</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239938.html</guid>
		</item>
		<item>
			<title>factory design or shared laibrary</title>
			<link>http://www.daniweb.com/forums/thread239924.html</link>
			<pubDate>Fri, 20 Nov 2009 05:14:03 GMT</pubDate>
			<description>Hi, 
 
some time back i faced question like this. 
we ca use factory design using factory desing implementation. we can do the same using the shared laibrary, like we will have  a static function in the shared laibrary which will be returning pointer to base class object. what is the difference...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
some time back i faced question like this.<br />
we ca use factory design using factory desing implementation. we can do the same using the shared laibrary, like we will have  a static function in the shared laibrary which will be returning pointer to base class object. what is the difference between these two ?<br />
<br />
i hope u people got my question.<br />
</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>tarakant_sethy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239924.html</guid>
		</item>
		<item>
			<title>Bad parameter: A bad object array</title>
			<link>http://www.daniweb.com/forums/thread239915.html</link>
			<pubDate>Fri, 20 Nov 2009 04:19:57 GMT</pubDate>
			<description><![CDATA[Hello All, 
  I am creating the array of size: 26627664 bytes then convert the byte to char array. 
  While deleting the array i got an code gaurd log error that Bad Parameter. 
 
I am doing like this 
Char* pBuffer = (Char*)new BYTE[26627664]; 
 
and deleting like this, 
if(pBuffer != NULL) 
     ...]]></description>
			<content:encoded><![CDATA[<div>Hello All,<br />
  I am creating the array of size: 26627664 bytes then convert the byte to char array.<br />
  While deleting the array i got an code gaurd log error that Bad Parameter.<br />
<br />
I am doing like this<br />
Char* pBuffer = (Char*)new BYTE[26627664];<br />
<br />
and deleting like this,<br />
if(pBuffer != NULL)<br />
            delete[] pBuffer;<br />
facing the problem<br />
Please Help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>SagarSonu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239915.html</guid>
		</item>
		<item>
			<title>Help!!!!!</title>
			<link>http://www.daniweb.com/forums/thread239895.html</link>
			<pubDate>Fri, 20 Nov 2009 03:01:28 GMT</pubDate>
			<description><![CDATA[// I am new to C++ and can not seem to get the falling man to output to the screen. Any help would be greatly appreciated. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>// I am new to C++ and can not seem to get the falling man to output to the screen. Any help would be greatly appreciated.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; #include &lt;iostream&gt;<br />
&nbsp; &nbsp; #include &lt;windows.h&gt;<br />
&nbsp; &nbsp; using namespace std;<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; void DrawBar(char guess);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; int main()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; char solution[8]; //holds solution<br />
&nbsp; &nbsp; &nbsp; &nbsp; char blank[8]; //holds &quot;*&quot;'s for unsolved letters<br />
&nbsp; &nbsp; &nbsp; &nbsp; int counter = 0; //general-use counter<br />
&nbsp; &nbsp; &nbsp; &nbsp; int right = 0; //1 = right guess, 0 = wrong guess.<br />
&nbsp; &nbsp; &nbsp; &nbsp; char guess;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter phrase 8 chars or less.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.getline(solution, 8);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int puzzLength = strlen(solution); //finds lengtrh of puzzle, stores INT value to puzzlength<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; //convert puzzle to full uppercase<br />
&nbsp; &nbsp; for (counter = 0; counter &lt; puzzLength; counter++){<br />
&nbsp; &nbsp; &nbsp;  solution[counter] = toupper(solution[counter]);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; //done converting<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; strcpy_s(blank, solution); //copy solution to the 'blank' array<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; for (counter = 0; counter &lt; puzzLength; counter++) { //converts characters to _'s to represent blanks<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  if (isalnum(solution[counter])) blank[counter] = '_';<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp;  else blank[counter] = solution[counter];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; } //closes for loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; while (strcmp(solution, blank)) { //play game until the 'blank' puzzle becomes the 'right' answer<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;&quot;Solution phrase is: &quot;&lt;&lt;solution&lt;&lt;&quot;.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;The current 'blank' puzzle is: &quot;&lt;&lt;blank&lt;&lt;&quot;.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Enter a guess.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cin&gt;&gt;guess;<br />
&nbsp; &nbsp; guess = toupper(guess);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; //cbeck guess!<br />
&nbsp; &nbsp; for (counter = 0; counter &lt;= puzzLength; counter++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (guess == solution[counter]) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; blank[counter] = guess; //fill in the puzzle with the letter<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; } //close loop, done checking guess<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; } //game is over.<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Winner!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.get();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
//DrawBar(guess);&nbsp; &nbsp; &nbsp; &nbsp; //Draw the hanging bar at end of game<br />
&nbsp; &nbsp; &nbsp; &nbsp; //They lost if they are here so tell them the answer.<br />
&nbsp; &nbsp; &nbsp; &nbsp; //cout&lt;&lt;&quot;The word was : &quot;&lt;&lt;Words[Word]&lt;&lt;endl&lt;&lt;endl;&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
<br />
// This will Draw the hanging bar according to the state<br />
void DrawBar(char guess)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(guess==5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  /|\\&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  / \\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; 0&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  /|\\&nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  / \\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  0&nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; /|\\&nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  0&nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +---------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; \\0&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp;  |\\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; / \\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +----------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; \\0/&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp;  |&nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; / \\&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +-----------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; 0_:__:&nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp;  \\&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +-----------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; 0_:__:&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>KRal</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239895.html</guid>
		</item>
		<item>
			<title>Segmentation fault. help plz!</title>
			<link>http://www.daniweb.com/forums/thread239890.html</link>
			<pubDate>Fri, 20 Nov 2009 01:45:50 GMT</pubDate>
			<description>So i need help figurin out where my segmentation fault is comin from. Im not even close to finishing this program but i was just testing my progress so far to make sure that it was taking values correctly, but sometimes the program doesnt stop when its supposed to and when it does i get a...</description>
			<content:encoded><![CDATA[<div>So i need help figurin out where my segmentation fault is comin from. Im not even close to finishing this program but i was just testing my progress so far to make sure that it was taking values correctly, but sometimes the program doesnt stop when its supposed to and when it does i get a segmentation fault at the end, even if it works the way i want it to.<br />
<br />
heres the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream&gt;<br />
using namespace std;<br />
<br />
class Heapsort<br />
{<br />
&nbsp; private:<br />
&nbsp; &nbsp;  int mylist[];<br />
&nbsp; &nbsp;  int mysize;<br />
&nbsp; public:<br />
&nbsp; &nbsp;  void get_size();<br />
&nbsp; &nbsp;  bool empty();<br />
&nbsp; &nbsp;  void sort();<br />
&nbsp; &nbsp;  void fill_array();<br />
&nbsp; &nbsp;  void print(int);<br />
};<br />
<br />
<br />
void Heapsort::get_size()<br />
{<br />
&nbsp;  cout &lt;&lt;endl&lt;&lt;&quot;Please enter the size of the array you want to sort: &quot;;<br />
&nbsp;  cin &gt;&gt; mysize;<br />
&nbsp;  int mylist[mysize];<br />
}<br />
<br />
void Heapsort::fill_array()<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; int num;<br />
<br />
&nbsp; &nbsp; for (i=0; i &lt; mysize; i++){<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter a number 1-100: &quot;;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; num;<br />
&nbsp; &nbsp; &nbsp;  if ((num &lt; 1)||(num &gt; 100)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\n\nEnter a correct number please.\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  i = i - 1;<br />
&nbsp; &nbsp; &nbsp;  } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  mylist[i] = num;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; Heapsort heap;<br />
<br />
&nbsp; heap.get_size();<br />
<br />
&nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
<br />
&nbsp; heap.fill_array();<br />
<br />
&nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; <br />
&nbsp; return (0);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bigmaq</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239890.html</guid>
		</item>
		<item>
			<title>Tic-Tac-DOH!!</title>
			<link>http://www.daniweb.com/forums/thread239880.html</link>
			<pubDate>Fri, 20 Nov 2009 01:18:51 GMT</pubDate>
			<description>Here is my assignment.   
5.	Assignment:  Using the code given below develop a solution to the game Tic-Tac-Toe. 
a.	The game is played between a human user and the computer.  The computer’s moves are made randomly.  You must get 3-in-a-row to win; getting five of the nine squares is a tie game.  ...</description>
			<content:encoded><![CDATA[<div>Here is my assignment.  <br />
5.	Assignment:  Using the code given below develop a solution to the game Tic-Tac-Toe.<br />
a.	The game is played between a human user and the computer.  The computer’s moves are made randomly.  You must get 3-in-a-row to win; getting five of the nine squares is a tie game.  <br />
b.	Use proper designing strategies. All input and output should be done in a single module (I/O should not be done in strategy modules).  Have an introduction screen that explains how to play the game, let the user know the computer’s move at each turn, and have an ending screen announcing the winner.<br />
6.	Complete all function stubs and correct the logic of the main() to obtain a working program.<br />
<br />
The starting code;<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std; <br />
//Purpose: Prints to the screen the an introduction and <br />
// provides the rules of the game<br />
//Input: None<br />
//Output: None<br />
void Intro()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
{<br />
}<br />
//Purpose: allows the computer to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the computer's move <br />
void ComputerMove(char B[][3])&nbsp; &nbsp;  <br />
{ int i=0, turn=0;&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN COMPUTER MOVE \n&quot;;<br />
&nbsp;//while (turn==0)&nbsp; &nbsp;  //Make sure the move is ok<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; i=rand()%9+1;&nbsp; &nbsp;  //randomize a move<br />
&nbsp; &nbsp; &nbsp; if (i==1)&nbsp; &nbsp; &nbsp; // make sure the first location is not taken<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0]!='x')&amp;&amp;(B[0][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; /*********<br />
&nbsp; &nbsp; &nbsp; repeat the above check for all locations<br />
&nbsp; &nbsp; &nbsp; ***********/<br />
&nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
<br />
<br />
<br />
//Purpose: allows the user to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the human's move <br />
void HumanMove(char B[][3]) <br />
{int i=0, turn=0;<br />
cout&lt;&lt;&quot;\n IN HUMAN MOVE \n&quot;;<br />
/*************<br />
// the logic is similar to the computer move except that <br />
// it takes the location from the keyboard<br />
****************/<br />
}<br />
//Purpose: Print out the board<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: None<br />
void PrintBoard(char B[][3]) <br />
{&nbsp; &nbsp;  cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[0][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][2];&nbsp;  <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[1][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[2][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n\n&quot;;<br />
}<br />
//Purpose: Check for a winner<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: win and integer indicating winner status. <br />
//&nbsp; &nbsp; &nbsp;  0=no winner, 1= human winner, 2= computer winner<br />
int CheckWin(char B[][3])<br />
{&nbsp; &nbsp;  int win = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN CHECK WIN &quot;&lt;&lt;win&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; return (win);<br />
}<br />
void main ()<br />
{int choice=0, done=0, t=0, w=0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
char Board[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}};<br />
srand(time(0));<br />
Intro();<br />
PrintBoard(Board);<br />
cout&lt;&lt;&quot;Do you want to go first? Enter 1 for yes, 2 for no&quot;;<br />
cin&gt;&gt;choice;<br />
&nbsp; &nbsp; &nbsp; if (choice==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if player wishes to go first<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{ cout&lt;&lt;&quot;\n t = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;Youwin!&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{&nbsp;  cout&lt;&lt;&quot;\n t = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(w==1)&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; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
I took this code did all the hard work below;<br />
<br />
 <pre style="margin:20px; line-height:13px">//Michelle Stokes CSI130 Lab 13<br />
//Code from hand out Lab14 TTT<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std; <br />
//Purpose: Prints to the screen the an introduction and <br />
// provides the rules of the game<br />
//Input: None<br />
//Output: None<br />
void Intro()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;This game is played between a human user and the computer. \n&quot; &lt;&lt;&nbsp; &quot;The computers moves are made randomly. \n&quot; &lt;&lt;&nbsp; &quot;You must get 3-in-a-row to win; getting five of the nine squares is a tie game. \n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You player will be lower case 'x'.&nbsp; You will enter the number of the space you would like to play. \n&quot;;<br />
}<br />
//Purpose: allows the computer to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the computer's move <br />
void ComputerMove(char B[][3])&nbsp; &nbsp;  <br />
{ int i=0, turn=0;&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN COMPUTER MOVE \n&quot;;<br />
&nbsp;//while (turn==0)&nbsp; &nbsp;  //Make sure the move is ok<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; i=rand()%9+1;&nbsp; &nbsp;  //randomize a move<br />
&nbsp; &nbsp; &nbsp; if (i==1)&nbsp; &nbsp; &nbsp; // make sure the first location is not taken<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0]!='x')&amp;&amp;(B[0][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&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; else if (i==2)<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; if ((B[0][1]!='x')&amp;&amp;(B[0][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][1]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==3)<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; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][2]!='x')&amp;&amp;(B[0][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][2]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==4)<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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][0]!='x')&amp;&amp;(B[1][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==5)<br />
&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 ((B[1][1]!='x')&amp;&amp;(B[1][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][1]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==6)<br />
&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 ((B[1][2]!='x')&amp;&amp;(B[1][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][2]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&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; else if (i==7)<br />
&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 ((B[2][0]!='x')&amp;&amp;(B[2][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==8)<br />
&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 ((B[2][1]!='x')&amp;&amp;(B[2][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][1]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==9)<br />
&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 ((B[2][2]!='x')&amp;&amp;(B[2][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][2]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; }<br />
<br />
<br />
//Purpose: allows the user to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the human's move <br />
void HumanMove(char B[][3]) <br />
{int i=0, turn=0;<br />
cout&lt;&lt;&quot;\n IN HUMAN MOVE \n&quot;;<br />
//while (turn==0)&nbsp; &nbsp;  //Make sure the move is ok<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the number of the space you would like to move to: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; i;&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; if (i==1)&nbsp; &nbsp; &nbsp; // make sure the first location is not taken<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0]!='x')&amp;&amp;(B[0][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][0]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&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; else if (i==2)<br />
&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 ((B[0][1]!='x')&amp;&amp;(B[0][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][1]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==3)<br />
&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 ((B[0][2]!='x')&amp;&amp;(B[0][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][2]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==4)<br />
&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 ((B[1][0]!='x')&amp;&amp;(B[1][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][0]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==5)<br />
&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 ((B[1][1]!='x')&amp;&amp;(B[1][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][1]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&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; else if (i==6)<br />
&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 ((B[1][2]!='x')&amp;&amp;(B[1][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][2]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&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; else if (i==7)<br />
&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 ((B[2][0]!='x')&amp;&amp;(B[2][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][0]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==8)<br />
&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 ((B[2][1]!='x')&amp;&amp;(B[2][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][1]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; else if (i==9)<br />
&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 ((B[2][2]!='x')&amp;&amp;(B[2][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][2]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; }<br />
<br />
//Purpose: Print out the board<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: None<br />
void PrintBoard(char B[][3]) <br />
{&nbsp; &nbsp;  cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[0][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][2];&nbsp;  <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[1][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[2][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n\n&quot;;<br />
}<br />
//Purpose: Check for a winner<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: win and integer indicating winner status. <br />
//&nbsp; &nbsp; &nbsp;  0=no winner, 1= human winner, 2= computer winner<br />
int CheckWin(char B[][3])<br />
{&nbsp; &nbsp;  int win = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; if((B[0][0] == B[0][1] &amp;&amp; B[0][1] == B[0][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][0] == B[1][1] &amp;&amp; B[1][1] == B[1][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][0] == B[2][1] &amp;&amp; B[2][1] == B[2][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0] == B[1][1] &amp;&amp; B[1][1] == B[2][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][2] == B[1][1] &amp;&amp; B[1][1] == B[2][0]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0] == B[1][0] &amp;&amp; B[1][0] == B[2][0]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][1] == B[1][1] &amp;&amp; B[1][1] == B[2][1]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][2] == B[1][2] &amp;&amp; B[1][2] == B[2][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN CHECK WIN &quot;&lt;&lt;win&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; return (win);<br />
}<br />
void main ()<br />
{int choice=0, done=0, t=0, w=0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
char Board[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}};<br />
srand(time(0));<br />
Intro();<br />
PrintBoard(Board);<br />
cout&lt;&lt;&quot;Do you want to go first? Enter 1 for yes, 2 for no: &quot;;<br />
cin&gt;&gt;choice;<br />
&nbsp; &nbsp; &nbsp; if (choice==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if player wishes to go first<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{ cout&lt;&lt;&quot;\n turn = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;Youwin!&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{&nbsp;  cout&lt;&lt;&quot;\n turn = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
While still in the lab I was able to get the program going. However I can't get it to stop after someone wins, nor can I get the tie to work (might be related).<br />
<br />
Please help!  The program has to be in this format as he gave us the guide line and told us something in main was broken.... :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mitchstokes225</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239880.html</guid>
		</item>
		<item>
			<title>.h file of class</title>
			<link>http://www.daniweb.com/forums/thread239876.html</link>
			<pubDate>Fri, 20 Nov 2009 01:08:14 GMT</pubDate>
			<description><![CDATA[So this is just the beginning of my questions, but I'm seriously having problems using classes in C++, I'm writing a program right now to plot points using asterisks on a 40 by 40 plain.  right now I'm just trying to write the .h for the point class and i cant even get that to compile. 
 
heres...]]></description>
			<content:encoded><![CDATA[<div>So this is just the beginning of my questions, but I'm seriously having problems using classes in C++, I'm writing a program right now to plot points using asterisks on a 40 by 40 plain.  right now I'm just trying to write the .h for the point class and i cant even get that to compile.<br />
<br />
heres what I have followed by errors I'm receiving... any help in regards to classes or just help with the errors will be appreciated.<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
#ifndef POINT_H<br />
#define POINT_H<br />
<br />
#include &lt;iostream&gt;<br />
#include &quot;arrayholder.h&quot;<br />
<br />
class Point{<br />
<br />
&nbsp;public:<br />
&nbsp; Point(): x(0.0), y(0.0), next() {};<br />
<br />
&nbsp; void addPoint( char a&#91;&#93;&#91;&#93; );<br />
<br />
private:<br />
double x;<br />
double y;<br />
Point* next;<br />
<br />
};<br />
<br />
#endif</pre><br />
and my arrayholder.h file<br />
<br />
 <pre style="margin:20px; line-height:13px">#ifndef ARRAYHOLDER_H<br />
#define ARRAYHOLDER_H<br />
<br />
#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
#include &quot;rectangle.h&quot;<br />
#include &quot;point.h&quot;<br />
<br />
class arrayholder{<br />
<br />
private:<br />
char a&#91;40&#93;&#91;40&#93;;<br />
Point* listpointer;<br />
<br />
public:<br />
<br />
&nbsp;char** initarray();<br />
&nbsp;void printRect();<br />
&nbsp;void printPoints();<br />
};<br />
<br />
#endif</pre><br />
<br />
In file included from point.h:13:<br />
arrayholder.h:22: error: ISO C++ forbids declaration of `Point' with no type<br />
arrayholder.h:22: error: expected `;' before '*' token<br />
<br />
I'm getting the same two errors for rectangle.h</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Dewey1040</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239876.html</guid>
		</item>
		<item>
			<title>Link external stylesheet in Visual studio 2008</title>
			<link>http://www.daniweb.com/forums/thread239870.html</link>
			<pubDate>Fri, 20 Nov 2009 00:12:35 GMT</pubDate>
			<description><![CDATA[I'm making a project in Visual studio 2008.  
The details of the project are: 
- It is a MFC Application 
- The application type is Dialog based with Use HTML Dialog enabled 
- The project style is MFC standard and... 
- The use of the MFC is in a shared DLL 
 
When it creates the project, I have...]]></description>
			<content:encoded><![CDATA[<div>I'm making a project in Visual studio 2008. <br />
The details of the project are:<br />
- It is a MFC Application<br />
- The application type is Dialog based with Use HTML Dialog enabled<br />
- The project style is MFC standard and...<br />
- The use of the MFC is in a shared DLL<br />
<br />
When it creates the project, I have an HTML file called myApp.htm<br />
which contains the HTML code of the dialog.<br />
<br />
I want to apply an external css file to this HTML, so i add:<br />
&lt;link rel=&quot;stylesheet&quot; src=&quot;myApp.css&quot; type=&quot;text/css&quot;/&gt;<br />
in the head of the document. But it doesn't work.<br />
So I try using:<br />
&lt;link rel=&quot;stylesheet&quot; src=&quot;file://myApp.css&quot; type=&quot;text/css&quot;/&gt;<br />
but it doesn't work either.<br />
I think there must be a way to do it.<br />
I added the css file to the project.<br />
I have tried everything, but no luck. Can someone give me a hand?<br />
thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Tales</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239870.html</guid>
		</item>
		<item>
			<title><![CDATA[need help with using f'riend' to design this program. also, overloading.]]></title>
			<link>http://www.daniweb.com/forums/thread239868.html</link>
			<pubDate>Fri, 20 Nov 2009 00:03:41 GMT</pubDate>
			<description>Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute.  Overload extraction and insertion operations for the class. 
 
Overload the == operator to compare two PhoneCalls. Consider one PhoneCall to be equal to...</description>
			<content:encoded><![CDATA[<div>Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute.  Overload extraction and insertion operations for the class.<br />
<br />
Overload the == operator to compare two PhoneCalls. Consider one PhoneCall to be equal to another if both calls are placed to the same number.<br />
<br />
Create a main() function that allows you to enter 10 PhoneCalls into an array.  If a PhoneCall is already been placed to a number, do not allow a second PhoneCall to the same number<br />
<br />
<br />
<br />
I'm pretty good at logic so i think i can figure that part out, its the syntax and the declarations that i cant wrap my head around<br />
<br />
please help!<br />
thank you.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>simplyscottif</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239868.html</guid>
		</item>
		<item>
			<title>My Program wont Stop?</title>
			<link>http://www.daniweb.com/forums/thread239861.html</link>
			<pubDate>Thu, 19 Nov 2009 23:23:21 GMT</pubDate>
			<description>so i guess there must be some sort of an error in my logic but on line 119 i started a counter that only goes up when a pair is made in the game.  Since there are a total of 8 pairs, i set that when the counter is 8 the bool nullexists turns false.  when it is false it should skip the while loop...</description>
			<content:encoded><![CDATA[<div>so i guess there must be some sort of an error in my logic but on line 119 i started a counter that only goes up when a pair is made in the game.  Since there are a total of 8 pairs, i set that when the counter is 8 the bool nullexists turns false.  when it is false it should skip the while loop and output that you have won.<br />
<br />
Any ideas on what is actually wrong here? I did check and the counter is going up at the correct times<br />
<br />
here is the code<br />
 <pre style="margin:20px; line-height:13px">//*******************************************************************************************************************<br />
// Homework 5<br />
// <br />
//&nbsp; &nbsp;  <br />
//&nbsp; &nbsp;  <br />
//<br />
// This program is a matching game.&nbsp; The user uses a cordinant system to select<br />
// cards on a 4x4 board.<br />
// Input:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; the user inputs the cordinants of the cards they want to flip<br />
// Processing:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  the program randomly generates pairs of cards in random locations<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; on the 4x4 board.&nbsp; it also adjusts the user input so that the<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cordinants match with the matrix counting system.<br />
// Output:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  the game board, the cards fliped, if they match, and the next board piece<br />
//*******************************************************************************************************************<br />
<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; char comma;<br />
&nbsp; &nbsp; int row1, row1a, column1, column1a, row2, row2a, column2, column2a, cards[4][4], cards_unflipped[4][4] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} , counter(0), g(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool nullexists = true;<br />
&nbsp; &nbsp; srand((unsigned)time(NULL));<br />
&nbsp;  <br />
&nbsp; &nbsp; //fill board with pairs<br />
&nbsp; &nbsp; bool makeNext = false;<br />
&nbsp; &nbsp; memset(cards, 0, sizeof(cards));<br />
&nbsp; &nbsp; srand(time(NULL));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for( int i = 1; i &lt; 9; i++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makeNext = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!makeNext)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int x1, y1, x2, y2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y1 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y2 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( (x1 != x2 || y1 != y2) &amp;&amp; (cards[x1][y1] == 0 &amp;&amp; cards[x2][y2] == 0) )<br />
&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; cards[x1][y1] = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards[x2][y2] = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makeNext = true;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // initial display board<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
<br />
&nbsp;  //Game Loop --------------------------------------------------------------------------------<br />
&nbsp;  while (nullexists = true)<br />
<br />
&nbsp;  {<br />
&nbsp; &nbsp;  //selection of cards<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Please select the first card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; row1a &gt;&gt; comma &gt;&gt; column1a;<br />
<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please select the second card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row2a&gt;&gt;comma&gt;&gt;column2a;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // adjusting for matrix cordinants<br />
&nbsp; &nbsp; &nbsp; &nbsp; row1 = row1a - 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; row2 = row2a - 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; column1 = column1a - 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; column2 = column2a - 1;<br />
<br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // make sure that the cordinants are on the board<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (row1a &gt; 4 || row2a &gt; 4 || column1a &gt; 4 || column2a &gt; 4 || row1a &lt; 1 || row2a &lt; 1 || column1a &lt; 1 || column2a &lt; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;please pick cordinants on the board.&quot; &lt;&lt; endl &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please select the first card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; row1a &gt;&gt;comma &gt;&gt; column1a;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please select the second card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; row2a &gt;&gt; comma &gt;&gt; column2a;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // cards chosen<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The cards you picked were &quot; &lt;&lt; cards[row1][column1] &lt;&lt; &quot; and &quot; &lt;&lt; cards[row2][column2] &lt;&lt; endl;<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  if (cards[row1][column1]== cards[row2][column2])<br />
<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = cards[row1][column1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = cards[row2][column2];<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter = counter++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (counter == 8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool nullexists = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (bool nullexists = false)<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; cout &lt;&lt; &quot; Congrats, You Won!&quot; &lt;&lt; endl;<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; }<br />
<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; cout &lt;&lt; &quot;Press n to continue.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (1)<br />
&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;  if (getchar() == 'n')<br />
&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; break;<br />
&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;  }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // move to blank screen<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (g=0; g &lt;= 20; g++)<br />
&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; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; //reveal the flipped cards<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = cards[row1][column1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = cards[row2][column2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //reveal the flipped cards<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&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; cout&lt;&lt;&quot;-&quot;;<br />
&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; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&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; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<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; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // pause for user to look at the cards they flipped<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Press n to continue.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (getchar() == 'n')<br />
&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; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //reset flipped cards<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = 0;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // move to blank screen<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (g=0; g &lt;= 20; g++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //reveal the flipped cards<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&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; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //GAME LOOP END -------------------------------------------------------------------------------<br />
<br />
&nbsp;  cout &lt;&lt; &quot;You Won!&quot; &lt;&lt; endl;<br />
&nbsp;<br />
<br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ponomous</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239861.html</guid>
		</item>
		<item>
			<title>Confused about my pseudocodes</title>
			<link>http://www.daniweb.com/forums/thread239860.html</link>
			<pubDate>Thu, 19 Nov 2009 23:03:29 GMT</pubDate>
			<description><![CDATA[Pseudocode is still somewhat confusing and I've been reading and this assignment for the a while now and I wanted to make sure I am understanding what's being asked of me. Could someone please tell me if my pseudocodes are correct? 
 
Question: 
 
1. Using pseudocode declare a Real number named...]]></description>
			<content:encoded><![CDATA[<div>Pseudocode is still somewhat confusing and I've been reading and this assignment for the a while now and I wanted to make sure I am understanding what's being asked of me. Could someone please tell me if my pseudocodes are correct?<br />
<br />
Question:<br />
<br />
1. Using pseudocode declare a Real number named temperature.<br />
<br />
2. Using pseudocode declare a variable to store the Julian day (1-366) named JDay<br />
<br />
3. Write pseudocode that asks a user to enter string variables to store a person’s lastname and  birthdate. Then output the lastname and birthdate separated by a comma.<br />
<br />
<br />
My pseudocode:<br />
<br />
1. Declare temperature as double<br />
<br />
2. Declare JDay as Integer<br />
<br />
3. Declare LastName as string<br />
Declare BirthDate as string<br />
Write “Enter your last name”<br />
Input LastName<br />
Write “Enter your birthdate”<br />
Input BirthDate<br />
Set UserInfo = LastName = “ , “ + Birthdate</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>confusedndazed</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239860.html</guid>
		</item>
		<item>
			<title>Reverse number</title>
			<link>http://www.daniweb.com/forums/thread239856.html</link>
			<pubDate>Thu, 19 Nov 2009 22:35:12 GMT</pubDate>
			<description><![CDATA[Hi, I wounder if anyone can help me start a program which takes "USER INPUT" for any 10 numbers and then print them in reverse order using arrays what should I need to do to get started with this. Please help. 
 
Thanks, 
Maverick]]></description>
			<content:encoded><![CDATA[<div>Hi, I wounder if anyone can help me start a program which takes &quot;USER INPUT&quot; for any 10 numbers and then print them in reverse order using arrays what should I need to do to get started with this. Please help.<br />
<br />
Thanks,<br />
Maverick</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239856.html</guid>
		</item>
		<item>
			<title>reading date using classes</title>
			<link>http://www.daniweb.com/forums/thread239849.html</link>
			<pubDate>Thu, 19 Nov 2009 21:29:02 GMT</pubDate>
			<description>hello  
i have given a program which uses the class. It reads the date of birth. And do all the necessary checks on the given value. e.g. What is the limit of that particular month, whether it is a leap year or not. I am writting the first program using classes. I am having problemin my switch...</description>
			<content:encoded><![CDATA[<div>hello <br />
i have given a program which uses the class. It reads the date of birth. And do all the necessary checks on the given value. e.g. What is the limit of that particular month, whether it is a leap year or not. I am writting the first program using classes. I am having problemin my switch statements which i used for checks the more I try to solve the more I get confused. Need your help. Please check my program. I know it is having many other mistakes also.<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream.h&gt;<br />
#include&lt;conio.h&gt;<br />
class date<br />
{<br />
public:<br />
date();<br />
void setdate(int, char, int);<br />
void printdate();<br />
private:<br />
int day;<br />
char month[50];<br />
int year;<br />
};<br />
date::date()<br />
{<br />
day=1;<br />
month= 'January';<br />
year= 1990;<br />
}<br />
void date::setdate(int d, char m[50], int y)<br />
{<br />
day = d;<br />
month =m; <br />
year = (y&gt;= 1900 &amp;&amp; y&lt;= 3000)? y : 1900;<br />
switch (m)<br />
{<br />
case 1: 'January'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 2: 'Febrary'<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; if (y%4==0)<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=29;<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=28;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; break;<br />
case 3: 'March'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 4: 'Apirl'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 5: 'May'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 6: 'June'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 7: 'July'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 8: 'August'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 9: 'September'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 10: 'October'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 11: 'November'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 12: 'December'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
}<br />
}<br />
void date::printdate()<br />
{<br />
cout&lt;&lt;day&lt;&lt;&quot; &quot;&lt;&lt;month&lt;&lt;&quot; &quot;&lt;&lt;year&lt;&lt;endl;<br />
}<br />
void main()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; date da;<br />
&nbsp; &nbsp; da.setdate(20,Febrary,1990)<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;The date of birth is : &quot;;<br />
&nbsp; &nbsp; da.printdate;<br />
&nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>the great</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239849.html</guid>
		</item>
		<item>
			<title>functions that take in iostream as parameter</title>
			<link>http://www.daniweb.com/forums/thread239839.html</link>
			<pubDate>Thu, 19 Nov 2009 20:33:21 GMT</pubDate>
			<description><![CDATA[I recently needed to add member functions like these into my class 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>I recently needed to add member functions like these into my class<br />
<br />
 <pre style="margin:20px; line-height:13px">istream&amp; read(istream&amp;) ;<br />
ostream&amp; print(ostream&amp;);</pre><br />
I am a little confused on how to actually call these functions within my class. I am more familiar with overloading the insertion and extraction operator since the prototype for those makes a lot more sense to me; however, one of my program spec is that I need to use these. What do I need to put into the function as a parameter?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>red999</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239839.html</guid>
		</item>
		<item>
			<title>Please Help Me with this little bug in my program (Program due in 8 hrs)</title>
			<link>http://www.daniweb.com/forums/thread239833.html</link>
			<pubDate>Thu, 19 Nov 2009 19:58:45 GMT</pubDate>
			<description><![CDATA[My program deals with the Genetic Algorithm and Hill Climber Algorithm. I have a program that compiles without any errs, its just the data is gives is incorrect. I explain my error on the bottom part of my post 
 
Header File 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>My program deals with the Genetic Algorithm and Hill Climber Algorithm. I have a program that compiles without any errs, its just the data is gives is incorrect. I explain my error on the bottom part of my post<br />
<br />
Header File<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
//------------------------------------------------------------------------------<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; class redefinedVector<br />
&nbsp;  {<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; redefinedVector();<br />
&nbsp; &nbsp; &nbsp; int get_size() const; <br />
&nbsp; &nbsp; &nbsp; int get_capacity() const; <br />
&nbsp; &nbsp; &nbsp; void push_back(T);<br />
&nbsp; &nbsp; &nbsp; void pop(); <br />
&nbsp; &nbsp; &nbsp; void resize(); <br />
&nbsp; &nbsp; &nbsp; void print(); <br />
&nbsp; &nbsp; &nbsp; T&amp; operator[](int index); <br />
&nbsp; &nbsp; &nbsp; ~redefinedVector(); <br />
&nbsp; <br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; T *basket; <br />
&nbsp; &nbsp; &nbsp; int capacity, size;<br />
&nbsp;  };<br />
//------------------------------------------------------------------------------&nbsp;  <br />
&nbsp; &nbsp; class Individual<br />
&nbsp;  {<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; friend class GeneticAlgorithm;<br />
&nbsp; &nbsp; &nbsp; friend class HillClimberAlgorithm;<br />
&nbsp; &nbsp; &nbsp; friend class UserInterface;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; Individual(); <br />
&nbsp; &nbsp; &nbsp; Individual(int problem); <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; double randomization(double, double); <br />
&nbsp; &nbsp; &nbsp; double GetData(int index) const;<br />
&nbsp; &nbsp; &nbsp; double GetFitness() const<br />
&nbsp; &nbsp; &nbsp;  { <br />
&nbsp; &nbsp; &nbsp; &nbsp;  return fitness;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; void SetProblem(int problem);<br />
&nbsp; &nbsp; &nbsp; void MathProblemsFitness();&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void setData(int index,double numbers); <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; int getProblem()const<br />
&nbsp; &nbsp; &nbsp;  { <br />
&nbsp; &nbsp; &nbsp; &nbsp;  return problem;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; double data[30]; <br />
&nbsp; &nbsp; &nbsp; double fitness; <br />
&nbsp; &nbsp; &nbsp; double max; <br />
&nbsp; &nbsp; &nbsp; double min; <br />
&nbsp; &nbsp; &nbsp; int problem; <br />
&nbsp;  };<br />
&nbsp;<br />
//------------------------------------------------------------------------------<br />
<br />
class UserInterface<br />
&nbsp;  {<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; UserInterface();<br />
&nbsp; &nbsp; &nbsp; UserInterface(bool parameters, bool Problem, bool Optimization); <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void setTimeResult(int,int);<br />
&nbsp; &nbsp; &nbsp; void setDataResult(int,Individual);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; Individual GetDataResult(int)const;&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; int getTimeResult(int) const;<br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; int highestTimes [3];<br />
&nbsp; &nbsp; &nbsp; Individual best [3];<br />
&nbsp;  }; <br />
//------------------------------------------------------------------------------ <br />
&nbsp;class GeneticAlgorithm<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  friend class UserInterface;<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; GeneticAlgorithm(); <br />
&nbsp; &nbsp; &nbsp; GeneticAlgorithm(int,int,double,double); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; redefinedVector&lt;Individual&gt; individualResults;<br />
&nbsp; &nbsp; &nbsp; redefinedVector&lt;int&gt; iterationVector;<br />
&nbsp; &nbsp; &nbsp; redefinedVector&lt;Individual&gt; mainVector;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; int selection(int); <br />
&nbsp; &nbsp; &nbsp; int randomization(int,int); <br />
&nbsp; &nbsp; &nbsp; int checkAnswer(); <br />
&nbsp; &nbsp; &nbsp; int rando(double);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; double randomizationDouble(double min, double max);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void Breed(int,int,int,double,double); <br />
&nbsp; &nbsp; &nbsp; void replace(Individual);&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void Optimize(int, int,double,double);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; int parent1, parent2;<br />
&nbsp; &nbsp; &nbsp; int iterationNumber; <br />
&nbsp;  };<br />
//------------------------------------------------------------------------------<br />
class HillClimberAlgorithm<br />
{<br />
&nbsp; &nbsp; &nbsp; public:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  HillClimberAlgorithm ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  HillClimberAlgorithm(int problem, double mutation_chance, double mutation_amount);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  redefinedVector&lt;Individual&gt; finalHillClimber;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  redefinedVector&lt;int&gt;runTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  redefinedVector&lt;Individual&gt; hillVector;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int randomization(int,int); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int checkAnswer();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int rando(double mutation_rate);<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  double randomizationDouble(double min, double max);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void replace(Individual individual);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; private:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int inidividualA, individualB;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int counter;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  double fitness;<br />
};</pre><br />
Implementation<br />
 <pre style="margin:20px; line-height:13px">#include &lt;cmath&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;ctime&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;sstream&gt;<br />
#include &lt;stdexcept&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;ctype.h&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;cctype&gt;<br />
#include &lt;algorithm&gt;<br />
#include &lt;iterator&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;math.h&gt;<br />
#include &quot;bpt0004_3.h&quot;<br />
<br />
using namespace std;<br />
using std :: ifstream;<br />
using std :: ofstream;<br />
using std :: endl;<br />
<br />
template&lt;class T&gt;<br />
&nbsp; &nbsp; redefinedVector&lt;T&gt;::redefinedVector() :capacity(2), size(0)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; basket = new T [capacity];<br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::push_back(T element)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; if(size &lt; capacity)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  basket[size] = element; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  size++;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  resize();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  basket[size] = element;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  size++; <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; T&amp; redefinedVector&lt;T&gt;::operator[](int index)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; if(index &gt;= size) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Illegal index.&quot; &lt;&lt; endl; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  exit(0);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; return basket[index]; <br />
&nbsp;  }<br />
&nbsp; <br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::pop()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; if(size != 0)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  size--; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  capacity = size + 1; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  T *newBasket = new T[capacity]; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; size; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newBasket[i] = basket[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  delete [] basket; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  basket = newBasket; <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Vector is Empty.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; } <br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; redefinedVector&lt;T&gt;::~redefinedVector()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; delete [] basket;<br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::resize()<br />
&nbsp;  { <br />
&nbsp; &nbsp; &nbsp; T *newBasket = new T[capacity + 2]; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; size; i++) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newBasket[i] = basket[i];<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; delete [] basket; <br />
&nbsp; &nbsp; &nbsp; basket = newBasket; <br />
&nbsp; &nbsp; &nbsp; capacity += 2; <br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::print()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; size; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; basket[i] &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; int redefinedVector&lt;T&gt;::get_size() const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return size;<br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; int redefinedVector&lt;T&gt;::get_capacity() const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return capacity;<br />
&nbsp;  } <br />
//-----------------------------------------------------------------------------<br />
<br />
UserInterface::UserInterface()<br />
&nbsp;  {<br />
&nbsp;  }<br />
&nbsp;<br />
int UserInterface::getTimeResult(int index)const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return highestTimes[index];<br />
&nbsp;  }<br />
void UserInterface::setTimeResult(int index, int numbers)&nbsp; <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; highestTimes[index] = numbers;<br />
&nbsp;  } <br />
Individual UserInterface::GetDataResult(int index)const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return best[index];<br />
&nbsp;  }<br />
void UserInterface::setDataResult(int index, Individual indiv)&nbsp; <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; best[index] = indiv;<br />
&nbsp;  }<br />
UserInterface::UserInterface(bool parameters, bool Problem, bool Optimization)<br />
&nbsp;  {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  /*<br />
&nbsp;  UserInterface Method that is the main menu for the user. Each bool parameter<br />
&nbsp;  ensures that values are entered into various parts within the menu.<br />
&nbsp;  */<br />
&nbsp;  srand (time(0));<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; bool sc = false;<br />
&nbsp; &nbsp; &nbsp; bool ro = false;<br />
&nbsp; &nbsp; &nbsp; bool gr = false;<br />
&nbsp; &nbsp; &nbsp; int userChoice = 0;<br />
&nbsp; &nbsp; &nbsp; int populationSize= 0; <br />
&nbsp; &nbsp; &nbsp; int problem =0;<br />
&nbsp; &nbsp; &nbsp; int algoChoice=0;<br />
&nbsp; &nbsp; &nbsp; double mutation_amount=0; <br />
&nbsp; &nbsp; &nbsp; double mutation_rate=0;<br />
&nbsp; &nbsp; &nbsp; bool menuBool=true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; while(userChoice != 6)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  do{ <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Function Optimizer:\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;1. Choose Algorithm \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;2. Choose Algorithm Parameters\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;3. Choose Problem (Schwefel, Rosenbrock, Griewangk).\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;4. Perform Optimization\n&quot;&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;5. Show All Optimization Results\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;6. Exit the System\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!(cin &gt;&gt; userChoice))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  while(userChoice &gt; 6 || userChoice &lt; 1); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(userChoice ==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter Algorithm Choice\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;1. HillClimber\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;2. GeneticAlgorithm\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!(cin &gt;&gt;algoChoice))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (algoChoice==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt;&quot;Hill Climber Chosen \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (algoChoice==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt;&quot;GeneticAlgorithm Chosen\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while((algoChoice &lt; 0)&amp;&amp;(algoChoice &gt;2));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(userChoice == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Enter parameters for each algorithm. Only the mutation amount and mutation\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;chance will be used for the Hillclimber, the Genetic will take in the muation \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;chance, mutation amount, and population size.\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter Mutation Amount(.03-1.0): &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; mutation_amount))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(mutation_amount &lt; -1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter Mutation Rate (.03-.25): &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; mutation_rate))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while(mutation_rate &lt; -1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter Population Size (2-50): &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; populationSize))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(populationSize &lt; 2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parameters = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Choose a problem (Schwefel, Rosenbrock, Griewangk).&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;1 Schwefel&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;2 Rosenbrock&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;3 Griewangk&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; problem))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(problem == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sc = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ro = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if(problem == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gr = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while(problem &gt; 3 || problem &lt; 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Problem = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 4)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!parameters || !Problem)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Error&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (algoChoice==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  HillClimberAlgorithm(problem, mutation_rate, mutation_amount);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Optimization = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (algoChoice==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  GeneticAlgorithm(problem,populationSize,mutation_rate,mutation_amount);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Optimization = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!Optimization)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Optimization not run&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(sc == true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Iterations: &quot; &lt;&lt; highestTimes[0] &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Schwefel information empty\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot; &quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(ro == true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Iterations: &quot; &lt;&lt; highestTimes[1] &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Rosenbrock information empty\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot; &quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(gr == true)<br />
&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; cout &lt;&lt;&quot;Iterations: &quot; &lt;&lt; highestTimes[2] &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Griewangk information empty&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 6)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Exiting&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp;  <br />
&nbsp;  }<br />
//------------------------------------------------------------------------------<br />
HillClimberAlgorithm::HillClimberAlgorithm() <br />
<br />
{<br />
}<br />
void HillClimberAlgorithm::replace(Individual newIndividual)<br />
/*Replace takes the least fit individual and replaces it the the newIndividual<br />
Pre-condition: takes in a newIndividual of type Individual, which sets a vector of random integers between a range<br />
determined by the problem.<br />
Post-condition replaces the current individual at hillvector[i] with the newIndividual<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double temp = hillVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; int index = 0; <br />
&nbsp; &nbsp; &nbsp; for(int i = 1; i &lt; hillVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(temp &lt; hillVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = hillVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = i; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  hillVector[index].setData(i,newIndividual.GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  hillVector[index].MathProblemsFitness();<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; counter++;<br />
&nbsp; &nbsp;  }<br />
int HillClimberAlgorithm::rando(double mutation_rate)<br />
/*<br />
Pre-condition: user entered mutation_rate<br />
Post-condition: generates a random double based on the mutation_rate<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double number = rand() / (double)RAND_MAX;<br />
&nbsp; &nbsp; &nbsp; return number &lt; mutation_rate;<br />
&nbsp;  }<br />
int HillClimberAlgorithm::randomization(int min, int max)<br />
/*<br />
Pre-condition: 2 integers<br />
Post-condition: random generated integer between the range of min and max<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;int&gt;(( static_cast&lt;double&gt;(rand()))/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min);<br />
&nbsp;  }<br />
double HillClimberAlgorithm::randomizationDouble(double min, double max)<br />
/*<br />
Pre-condition: 2 double<br />
Post-condition: random generated double between the range of min and max<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min;<br />
&nbsp;  }<br />
HillClimberAlgorithm::HillClimberAlgorithm(int problem, double mutation_rate, double mutation_amount)<br />
/*<br />
Main constructor used in the HillClimber Algorithm<br />
Pre-condition: takes in three parameters: problem, mutation_rate, mutation_amount<br />
Post-condition: Passes the Individual through the MathProblemsFitness and generates a fitness,<br />
if the fitness is less than the current fitness, than the newIndividual replaces individual<br />
*/<br />
{<br />
&nbsp; &nbsp; &nbsp;  Individual newIndividualA(problem);<br />
&nbsp; &nbsp; &nbsp;  fitness= newIndividualA.GetFitness();<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  double range=0;<br />
&nbsp; &nbsp; &nbsp;  if(problem == 1) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 131.072;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 4.096;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 1200;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  while( fitness &lt; .1)<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int chance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int choice = rando(mutation_rate);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int selection = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  selection = randomization(1,2);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  Individual newIndividualB;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(choice == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double newData = hillVector[selection].GetData(i); //get the data from the chosen parent<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newData = newData + range*(randomizationDouble(0,2)-1)*mutation_amount; //mutate it occording to the formula<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newIndividualB.setData(i,newData); //set the new data into the corresponding index of the child object<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(newData &gt; range/2) //if the number goes out of the upper bounds<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  newIndividualB.setData(i,range/2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(newData &lt; ((range/2)*-1)) //if the number gooes out of the lower bounds<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  newIndividualB.setData(i,((range/2)*-1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newIndividualB.setData(i,hillVector[selection].GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int iterations=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Individual newIndividualB (problem);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  newIndividualB.setData(i,newIndividualB.GetData(i)+newIndividualB.GetData(i)*((static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(2-0 + 1) + 0))*mutation_amount); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  double newFitness=newIndividualB.GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  iterations++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (newFitness &lt; fitness)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  { newIndividualB.MathProblemsFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  replace(newIndividualB);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; iterations &lt;&lt; endl;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  }<br />
//------------------------------------------------------------------------------<br />
Individual::Individual() <br />
&nbsp;  {<br />
&nbsp;  }<br />
&nbsp; <br />
double Individual::GetData(int index) const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return data[index]; <br />
&nbsp;  }<br />
&nbsp; <br />
void Individual::setData(int index, double numbers) <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; data[index] = numbers;<br />
&nbsp;  }<br />
&nbsp; <br />
void Individual::SetProblem(int Problem) <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; problem = Problem; <br />
&nbsp;  }<br />
<br />
Individual::Individual(int problem)<br />
/*<br />
Creates a new individual, and based on the problem, enters random values into <br />
a vector and passes that vector through MathProblemsFitness to create a fitness<br />
<br />
Pre-condition:user entered problem<br />
Post-condition: New individual created based on the problem choice and a fitness calculated<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; SetProblem(problem); <br />
&nbsp; &nbsp; &nbsp; if(problem == 1)<br />
&nbsp; &nbsp; &nbsp; {&nbsp; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  data[i] = randomization(-65.536,65.536);<br />
&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  data[i] = randomization(-2.048,2.048);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 3)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  data[i] = randomization(-600,600);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; MathProblemsFitness();<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp;double Individual::randomization(double min, double max) <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min;<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; void Individual::MathProblemsFitness()<br />
&nbsp; &nbsp; /*<br />
&nbsp; &nbsp; MathProblemsFitness defines the three math probelems (Schwefel, Rosenbrock, Griewangk)<br />
&nbsp; &nbsp; each vector from individual passes through these problems to calculate a fitness<br />
&nbsp; &nbsp; */<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double holder = 0;<br />
&nbsp; &nbsp; &nbsp; double temp2 = 1;<br />
&nbsp; &nbsp; &nbsp; fitness = 0; <br />
&nbsp; &nbsp; &nbsp; int next = 1; <br />
&nbsp; &nbsp; &nbsp; if(problem == 1) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int j = 0; j &lt; next; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  holder = holder + data[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; next++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fitness = fitness + (holder*holder);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 29; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 100*(data[i+1]-(data[i]*data[i]))*(data[i+1]-(data[i]*data[i])) + (data[i] - 1)*(data[i] - 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fitness = fitness + holder;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 3)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = (data[i]*data[i])/4000;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fitness = fitness+ holder;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  fitness = fitness + 1;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = cos(data[i]/sqrt(i+1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp2 = temp2 * holder;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  fitness = fitness - temp2;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
//------------------------------------------------------------------------------&nbsp; &nbsp; <br />
GeneticAlgorithm::GeneticAlgorithm() <br />
&nbsp;  {<br />
&nbsp; <br />
&nbsp;  }<br />
&nbsp; <br />
&nbsp; GeneticAlgorithm::GeneticAlgorithm(int problem, int populationSize, double mutation_rate, double mutation_amount)<br />
&nbsp; /*<br />
&nbsp; Builds the population of individuals and pushes it into the mainVector, then loop through 5 times<br />
&nbsp; until the desired value is reached.<br />
&nbsp; */<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; UserInterface m;<br />
&nbsp; &nbsp; &nbsp; int iterations;<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 5;&nbsp; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  iterationNumber = 0; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; populationSize; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Individual I(problem); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainVector.push_back(I); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int foundIt = 0; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  checkAnswer(); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  while(foundIt == 0 &amp;&amp; iterationNumber &lt; 5000000) <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foundIt = checkAnswer();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Optimize(problem, populationSize,mutation_rate, mutation_amount); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foundIt++;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  int index = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  double temp = mainVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 1; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(temp &gt; mainVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  temp = mainVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  index = i; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  individualResults.push_back(mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  iterationVector.push_back(iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(problem == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(iterationNumber &lt; m.getTimeResult(0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setTimeResult(0,iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setDataResult(0,mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(iterationNumber &lt; m.getTimeResult(1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setTimeResult(1,iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setDataResult(1,mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(iterationNumber &lt; m.getTimeResult(2))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setTimeResult(2,iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setDataResult(2,mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; populationSize; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainVector.pop();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Results: \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; individualResults.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Individual Best: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int j = 0; j &lt; 30; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; individualResults[i].data[j] &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Fitness Level: &quot; &lt;&lt; individualResults[i].GetFitness() &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Iterations: &quot; &lt;&lt; iterationVector[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; individualResults.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  individualResults.pop();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  iterationVector.pop();<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp;  }<br />
<br />
<br />
&nbsp; &nbsp; <br />
void&nbsp; GeneticAlgorithm::Optimize(int problem, int populationSize, double mutRate, double mutAmount)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; parent1 = selection(populationSize);<br />
&nbsp; &nbsp; &nbsp; parent2= selection(populationSize);<br />
&nbsp; &nbsp; &nbsp; Breed(parent1,parent2,problem,mutRate,mutAmount); <br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; void GeneticAlgorithm::Breed(int parent1, int parent2, int problem, double mutation_rate,double mutation_amount)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; Individual child(problem); <br />
&nbsp; &nbsp; &nbsp; double range = 0;<br />
&nbsp; &nbsp; &nbsp; if(problem == 1) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 131.072;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 4.096;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 1200;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int selection = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  selection = randomization(1,2); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(selection == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection = parent1; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection = parent2; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int chance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int choice = rando(mutation_rate); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(choice == 1) <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double newData = mainVector[selection].GetData(i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newData = newData + range*(randomizationDouble(0,2)-1)*mutation_amount; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; child.setData(i,newData); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(newData &gt; range/2) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  child.setData(i,range/2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(newData &lt; ((range/2)*-1)) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  child.setData(i,((range/2)*-1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; child.setData(i,mainVector[selection].GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; child.SetProblem(mainVector[parent1].getProblem()); <br />
&nbsp; &nbsp; &nbsp; child.MathProblemsFitness(); <br />
&nbsp; &nbsp; &nbsp; replace(child); <br />
&nbsp;  }<br />
&nbsp; <br />
int GeneticAlgorithm::rando(double mutRate)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double number = rand() / (double)RAND_MAX;<br />
&nbsp; &nbsp; &nbsp; return number &lt; mutRate;<br />
&nbsp;  }<br />
<br />
void GeneticAlgorithm::replace(Individual child)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double temp = mainVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; int index = 0; <br />
&nbsp; &nbsp; &nbsp; for(int i = 1; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(temp &lt; mainVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = mainVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = i; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mainVector[index].setData(i,child.GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mainVector[index].MathProblemsFitness();<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; iterationNumber++; <br />
&nbsp;while (iterationNumber ==0)<br />
&nbsp; &nbsp; &nbsp; //if(iterationNumber %100 == 0) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  temp = mainVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 1; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(temp &gt; mainVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  temp = mainVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Best Fitness: &quot; &lt;&lt; iterationNumber &lt;&lt;&quot; &quot; &lt;&lt; temp &lt;&lt;endl; <br />
&nbsp; &nbsp; &nbsp; }&nbsp; <br />
<br />
&nbsp; &nbsp; <br />
&nbsp;  <br />
&nbsp;  }<br />
&nbsp; <br />
int GeneticAlgorithm::checkAnswer()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(mainVector[i].GetFitness() &lt; .1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
<br />
int GeneticAlgorithm::selection(int populationSize)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; int choice = rand() % populationSize;<br />
&nbsp; &nbsp; &nbsp; int choice2 = rand() % populationSize;<br />
&nbsp; &nbsp; &nbsp; if(mainVector[choice].GetFitness() &lt; mainVector[choice2].GetFitness())<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return choice;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return choice2;<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp;int GeneticAlgorithm::randomization(int min, int max)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;int&gt;(( static_cast&lt;double&gt;(rand()))/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min);<br />
&nbsp;  }<br />
&nbsp; <br />
&nbsp; &nbsp; double GeneticAlgorithm::randomizationDouble(double min, double max)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min;<br />
&nbsp;  }</pre><br />
and Main<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &quot;bpt0004_3.h&quot;<br />
<br />
using namespace std;<br />
<br />
int main() <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; bool parameters = false, Problem = false, Optimization = false; <br />
&nbsp; &nbsp; &nbsp; UserInterface(parameters, Problem, Optimization);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp;  }</pre><br />
My error:<br />
1. first choose 1, then choose 2 for genetic algorithm<br />
2. choose 2, then input parameters within the ranges given<br />
3. choose 3, and choose 1(schwefel)<br />
4. choose 4 to optimize<br />
5. choose 5 &lt;-----this displays the correct number of iterations<br />
6. choose 3, and choose 2 or 1(Rosenbrock or Griewangk)<br />
7. choose 4 to optimize<br />
8. choose 5 &lt;-----This displays the error<br />
<br />
Error<br />
Genetic Iterations Schwefel: -1209686560<br />
Genetic Iterations Rosenbrock: 1<br />
Genetic Iterations Griewangk: -1079226444<br />
<br />
<br />
Why am i getting negative numbers and why is the iterations for rosenbrock just 1?? Please help me, this program is due tonight.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bpt0004</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239833.html</guid>
		</item>
		<item>
			<title>Just after a little claification im on the right track</title>
			<link>http://www.daniweb.com/forums/thread239823.html</link>
			<pubDate>Thu, 19 Nov 2009 19:02:22 GMT</pubDate>
			<description>Good morning all, 
 
So i have started teaching myself C++ in preparation for taking software engineering at university next year, after many hours i have managed to put a simple program together, Im just asking if someone can tell me on in the right track to understanding what each function does...</description>
			<content:encoded><![CDATA[<div>Good morning all,<br />
<br />
So i have started teaching myself C++ in preparation for taking software engineering at university next year, after many hours i have managed to put a simple program together, Im just asking if someone can tell me on in the right track to understanding what each function does if i break it down, <br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;</pre>So the iostream allows for keyboard input and the namespace is where code is stored? <br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; x;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; y;</pre>So the user is inputting a number to replace the x and the y with a value, <br />
<br />
 <pre style="margin:20px; line-height:13px">float x = 0.0;<br />
float y = 0.0;</pre>This is setting the integer value to 0, allowing the user to input a number to replace the 0, and i am using float because of the decimal point <br />
<br />
 <pre style="margin:20px; line-height:13px"> float a = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float b = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float c = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float d = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float e = x;</pre>This is storing the input from the console window? not 100% sure on what its doing...<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; a += y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; b -= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; c *= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; d /= y;</pre>And i have no idea what this section does...<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x += y &quot; &lt;&lt; a &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x -= y &quot; &lt;&lt; b &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x *= y &quot; &lt;&lt; c &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x /= y &quot; &lt;&lt; d &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x %= y &quot; &lt;&lt; e &lt;&lt; endl;</pre>And this just outputs the information into the console window, Im pretty down with console output ;)<br />
<br />
As i said above, just looking for clarification that i have my mind on the right sort of track and am not embedding wrong information into my head.<br />
<br />
Thanks heaps in advance<br />
<br />
-Privoxy<br />
<br />
Edit:<br />
<br />
The full code in view<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
int main()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; float x = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float y = 0.0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; x;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; y;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; float a = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float b = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float c = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float d = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float e = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; a += y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; b -= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; c *= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; d /= y;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x += y &quot; &lt;&lt; a &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x -= y &quot; &lt;&lt; b &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x *= y &quot; &lt;&lt; c &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x /= y &quot; &lt;&lt; d &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x %= y &quot; &lt;&lt; e &lt;&lt; endl;<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Privoxy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239823.html</guid>
		</item>
		<item>
			<title>return value is deleted before being passed on... how to avoid?</title>
			<link>http://www.daniweb.com/forums/thread239821.html</link>
			<pubDate>Thu, 19 Nov 2009 18:46:14 GMT</pubDate>
			<description><![CDATA[polynomial polynomial :: derivative(void) 
{ 
	polynomial outpoly; 
	outpoly._coef = new double [_degree]; 
	outpoly._degree = (_degree-1); 
	for(int i=0; i<(_degree); i++) 
	{ 
		outpoly._coef[i]=(i+1)*_coef[i+1]; 
	} 
	return outpoly;]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">polynomial polynomial :: derivative(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; polynomial outpoly;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outpoly._coef = new double &#91;_degree&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outpoly._degree = (_degree-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; i&lt;(_degree); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outpoly._coef&#91;i&#93;=(i+1)*_coef&#91;i+1&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return outpoly;<br />
}<br />
<br />
//header:<br />
#pragma once<br />
<br />
#include &lt;complex&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;sstream&gt;<br />
<br />
using namespace std;<br />
<br />
class polynomial<br />
{<br />
&nbsp; private:<br />
&nbsp; &nbsp; double * _coef;<br />
&nbsp; &nbsp; int _degree;&nbsp; &nbsp; <br />
&nbsp; public:<br />
&nbsp; &nbsp; // constructors&nbsp; &nbsp; <br />
&nbsp; &nbsp; polynomial(void);&nbsp; <br />
&nbsp; &nbsp; polynomial(int degree, double * coef);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ~polynomial(void);<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; // at: evaluates the polynomial at x or z<br />
&nbsp; &nbsp; //&nbsp;  returns the real/complex value of the polynomial at x/z<br />
&nbsp; &nbsp; double at(double x) const;<br />
&nbsp; &nbsp; complex&lt;double&gt; at ( complex&lt;double&gt; z) const;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; polynomial derivative(void) const;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool isEmpty(void);<br />
&nbsp; &nbsp; &nbsp; &nbsp; string tostring(void);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; polynomial&amp; operator = (const polynomial&amp; rhs);<br />
&nbsp; &nbsp; friend ostream&amp; operator &lt;&lt; (ostream&amp; os, polynomial&amp; m);<br />
&nbsp; &nbsp; <br />
};<br />
<br />
//How I use it in main:<br />
double * coef;<br />
int degree;<br />
cout&lt;&lt; &quot;INPUT degree: &quot;;<br />
cin&gt;&gt;degree;<br />
coef = new double &#91;degree+1&#93;;<br />
for(int n = 0; n&lt;(degree+1); n++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;INPUT &quot; &lt;&lt; n &lt;&lt; &quot;th degree: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; coef&#91;n&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
}<br />
polynomial poly(degree, coef);<br />
cout&lt;&lt;&quot;INPUT converted to: &quot; &lt;&lt; poly&lt;&lt;endl;<br />
cout&lt;&lt;&quot;EVALUATE for x = &quot;;<br />
double x;<br />
cin &gt;&gt; x;<br />
cout &lt;&lt; poly &lt;&lt; &quot; = &quot; &lt;&lt; poly.at(x) &lt;&lt; endl;<br />
cout &lt;&lt; &quot;DERIVATIVE of fxn is: &quot; &lt;&lt; poly.derivative() &lt;&lt;endl;</pre><br />
I have code for handling polynomials via an array of coefficients. Now I want to create a function that returns its derivative in polynomial form.<br />
<br />
Unfortunately, the return value is deleted before it is passed on. I discovered this the hardway by following the debugger as closely as I could.<br />
<br />
How can I avoid this error?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>denizen08</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239821.html</guid>
		</item>
		<item>
			<title>Polynomial division</title>
			<link>http://www.daniweb.com/forums/thread239812.html</link>
			<pubDate>Thu, 19 Nov 2009 17:48:53 GMT</pubDate>
			<description><![CDATA[cout<<"hello,everybody!"; 
 
Can somebody come for the rescue? 
 
Please *My_problem(Is writing a fuction that divides two polynomials ) 
{ 
      return rescue; 
}]]></description>
			<content:encoded><![CDATA[<div>cout&lt;&lt;&quot;hello,everybody!&quot;;<br />
<br />
Can somebody come for the rescue?<br />
<br />
Please *My_problem(Is writing a fuction that divides two polynomials )<br />
{<br />
      return rescue;<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Rapmanseele</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239812.html</guid>
		</item>
		<item>
			<title>Counting vowels + consonants in string and using pointers</title>
			<link>http://www.daniweb.com/forums/thread239811.html</link>
			<pubDate>Thu, 19 Nov 2009 17:46:25 GMT</pubDate>
			<description><![CDATA[I'm confused with pointers. I'm not sure how to get the vowels to show up in Case A.  
 
Also, I would need help by how to get the program to run again after case A instead of ending the program after each case. Should it be in if/else statement instead of switch? Or use while loop with switch...]]></description>
			<content:encoded><![CDATA[<div>I'm confused with pointers. I'm not sure how to get the vowels to show up in Case A. <br />
<br />
Also, I would need help by how to get the program to run again after case A instead of ending the program after each case. Should it be in if/else statement instead of switch? Or use while loop with switch statement? <br />
<br />
Thanks and I appreciate any hints/help! :)<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;fstream&gt;<br />
#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
char* getStringFromUser();<br />
int consonants(char* str);&nbsp; //function to print out consonants<br />
int vowels(char* str);&nbsp; //function to print out vowels<br />
void stringCopy(char* str1, char* str2);<br />
<br />
int main ()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; //declare variables to use for storing user's input<br />
&nbsp; &nbsp; &nbsp; &nbsp; char choice; //first menu<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //declare variables to use for program<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool goagain = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int getNumStrings();<br />
&nbsp; &nbsp; &nbsp; &nbsp; fstream dataFile; //input stream for file&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // introduction to the program <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\n------------------------------------------------&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\nVowels &amp; Consonants&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataFile.open(&quot;stringFile.txt&quot;, ios::out | ios::app); //open file<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (! dataFile) // test for error<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Error opening file.\n&quot;;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\nPlease select from the following menu items:\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t A)&nbsp; Count the vowels of a string.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t B)&nbsp; Count the consonants of a string.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t C)&nbsp; Count both vowels and consonants of a string.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t D)&nbsp; Enter a string in the file.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t E)&nbsp; Count the number of strings in the file.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t F)&nbsp; Exit this program.\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t Enter A, B, C, D, E, or F: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; choice; //user choice of menu<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(choice)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'A':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; getStringFromUser();<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; cout &lt;&lt; vowels(line, vowels);<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; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'B':&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;choice B&quot;;&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; break;<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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'C':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;choice C&quot;; <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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'D':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;choice D&quot;; <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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'E':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;choice E&quot;;<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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'F':&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\n\nGoodbye!&quot; &lt;&lt; endl;&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; break;<br />
&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; default: cout &lt;&lt; &quot;That is an invalid choice.\n&quot;;<br />
&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; dataFile.close(); //close text file&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}//end of function<br />
<br />
char* getStringFromUser()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line[100];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a string: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.ignore();<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.getline(line, 100, '\n');<br />
}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
int vowels(char* str)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char vowelsArray[] = {'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u', '\0'};<br />
&nbsp; &nbsp; &nbsp; &nbsp; char *vowelsPtr = vowelsArray;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numVowels = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int count;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The vowels in the string are: &quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(*str != '\0')<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(count = 0; count &lt;10; count++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (*str == *vowelsPtr)<br />
&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; numVowels++; //Point to next element<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The vowels in the string are: &quot; &lt;&lt; *vowelsPtr &lt;&lt; endl;<br />
&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; }<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; str++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vowelsPtr = vowelsArray; //set vowelsPtr to first element again<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return numVowels;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kryz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239811.html</guid>
		</item>
		<item>
			<title>need help</title>
			<link>http://www.daniweb.com/forums/thread239810.html</link>
			<pubDate>Thu, 19 Nov 2009 17:36:59 GMT</pubDate>
			<description><![CDATA[Hi everyone!! I am Kevin, and I am new to this site. I am taking C++ classes and have trouble writing this program. I  know I have to use several "for" loops and "rand" commands to write it but i am not exactly sure how to do that?? so, please can anyone help me with this?  the question is: 
 
Use...]]></description>
			<content:encoded><![CDATA[<div>Hi everyone!! I am Kevin, and I am new to this site. I am taking C++ classes and have trouble writing this program. I  know I have to use several &quot;for&quot; loops and &quot;rand&quot; commands to write it but i am not exactly sure how to do that?? so, please can anyone help me with this?  the question is:<br />
<br />
Use a two dimensional array to solve the following problem. A company has four salesperson (1 to 4) who sell five different different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains:<br />
     1) salesperson number.<br />
     2) the product number.<br />
     3) total dollar value of the product sold that day.<br />
<br />
Each sales person passes between 0 to 5 sales slips perday. Assume that the information from all of the slips for last week is avaible. Write a program that will read all this information and summarize the total sales by salesperson by products. All totals should be stored in a two dimensional array sales. After processing all the information print the result in tabular format with each column representing a particular salesperson and each row representing a particular product. Cross total each row to get the total sales of each product and cross total each column to get the total sales by salesperson. your tabular printout should include these cross totals to the right of the totaled rows and bottom of the totaled columns.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kkevin</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239810.html</guid>
		</item>
		<item>
			<title>not sure why i am outputting all zeros</title>
			<link>http://www.daniweb.com/forums/thread239800.html</link>
			<pubDate>Thu, 19 Nov 2009 16:57:16 GMT</pubDate>
			<description><![CDATA[So this is a matching game, flip over two cards, if they match they stay up if not they flip over again.  I have the matching system and coordinate system working.  My problem is that when i use my array of zeros to "hide" the numbers, all that is ever output is the zeros. 
 
Any ideas on why this...]]></description>
			<content:encoded><![CDATA[<div>So this is a matching game, flip over two cards, if they match they stay up if not they flip over again.  I have the matching system and coordinate system working.  My problem is that when i use my array of zeros to &quot;hide&quot; the numbers, all that is ever output is the zeros.<br />
<br />
Any ideas on why this might be happening?  also any ideas on using something other than the number 0 for my grid? like an *? i couldn't figure out how to get an array to take them.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; char comma;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int row1, column1, row2, column2, cards[4][4], cards_unflipped[4][4] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} , counter(0);<br />
<br />
&nbsp; &nbsp; srand((unsigned)time(NULL));<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //fill board with pairs<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool makeNext = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool nullexists = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; memset(cards, 0, sizeof(cards));<br />
&nbsp; &nbsp; &nbsp; &nbsp; srand(time(NULL));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( int i = 1; i &lt; 9; i++ )<br />
&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; makeNext = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!makeNext)<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; int x1, y1, x2, y2;<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; x1 = rand()%4;<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; y1 = rand()%4;<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; x2 = rand()%4;<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; y2 = rand()%4;<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; if( (x1 != x2 || y1 != y2) &amp;&amp; (cards[x1][y1] == 0 &amp;&amp; cards[x2][y2] == 0) )<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; {<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; &nbsp; &nbsp; &nbsp; &nbsp; cards[x1][y1] = i;<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; &nbsp; &nbsp; &nbsp; &nbsp; cards[x2][y2] = i;<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; &nbsp; &nbsp; &nbsp; &nbsp; makeNext = true;;<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; }<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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( int i = 0; i &lt; 4; i++ )<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; for( int c = 0; c &lt; 4; c++ )<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; {<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; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; cards[i][c] &lt;&lt; &quot; &quot;;<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; }<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; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; //display board<br />
&nbsp;  while (nullexists = true)<br />
<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //selection<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please select the first card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row1&gt;&gt;comma&gt;&gt;column1;<br />
<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please select the second card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row2&gt;&gt;comma&gt;&gt;column2;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (cards[row1][column1]==cards[row2][column2])<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = cards[row1][column1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = cards[row2][column2];<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter = counter++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (counter == 8)<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; bool nullexists = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //reveal the flipped cards<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
<br />
&nbsp;  cout &lt;&lt; &quot;You Won!&quot; &lt;&lt; endl;<br />
&nbsp; <br />
<br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ponomous</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239800.html</guid>
		</item>
		<item>
			<title>Help with a big project if you can help.</title>
			<link>http://www.daniweb.com/forums/thread239786.html</link>
			<pubDate>Thu, 19 Nov 2009 15:37:42 GMT</pubDate>
			<description>I have a project that requires me to make a search engine for classes. If i were to enter Biology, then classes such as genetics, chemistry, anatomy and physiology are to show up. But the thing is i have the classes and their descriptions in a file and i was wondering if anyone can give me some...</description>
			<content:encoded><![CDATA[<div>I have a project that requires me to make a search engine for classes. If i were to enter Biology, then classes such as genetics, chemistry, anatomy and physiology are to show up. But the thing is i have the classes and their descriptions in a file and i was wondering if anyone can give me some pointers on how to atleast start the project. I really don't know how to group the classes together so that I can compare the words and come up with results....or is there a better way?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>reese27</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239786.html</guid>
		</item>
		<item>
			<title>Calculate percentage problem</title>
			<link>http://www.daniweb.com/forums/thread239792.html</link>
			<pubDate>Thu, 19 Nov 2009 15:10:16 GMT</pubDate>
			<description><![CDATA[hi, I'm trying to calculate the percentage of an ammount of boxes in C. Ex: 4400. 
I have the next code:  
#include<iostream.h> 
#include<conio.h> 
main() 
{ 
double a=2400; 
double b=8000; 
double per=0; 
per=2400*100/8000;]]></description>
			<content:encoded><![CDATA[<div>hi, I'm trying to calculate the percentage of an ammount of boxes in C. Ex: 4400.<br />
I have the next code: <br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream.h&gt;<br />
#include&lt;conio.h&gt;<br />
main()<br />
{<br />
double a=2400;<br />
double b=8000;<br />
double per=0;<br />
per=2400*100/8000;<br />
cout&lt;&lt;per;<br />
getch();<br />
}</pre>and return a negative value. I try to asign values at differents variables like:<br />
<br />
 <pre style="margin:20px; line-height:13px">double confused=241541;<br />
double moreconfused=145621;<br />
long int percf=1452145;<br />
cout&lt;&lt;confused&lt;&lt;endl&lt;&lt;moreconfused&lt;&lt;percf;</pre>and return negatives values too, <br />
please, somebody can help me?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bernaprog</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239792.html</guid>
		</item>
		<item>
			<title>help me to loop pls</title>
			<link>http://www.daniweb.com/forums/thread239755.html</link>
			<pubDate>Thu, 19 Nov 2009 13:49:51 GMT</pubDate>
			<description>this is the output 
when enter 1 
*********O* 
when enter 2 
********O** 
---------------------------- 
1*********O* 
2********O** 
3*******O*** 
4******O****</description>
			<content:encoded><![CDATA[<div>this is the output<br />
when enter 1<br />
*********O*<br />
when enter 2<br />
********O**<br />
----------------------------<br />
1*********O*<br />
2********O**<br />
3*******O***<br />
4******O****<br />
5*****O*****<br />
.<br />
.<br />
.<br />
.<br />
.<br />
.<br />
.<br />
<br />
help me plss<br />
tnx</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>xtian3</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239755.html</guid>
		</item>
		<item>
			<title>please take a look at this C++ MySQL issue and help</title>
			<link>http://www.daniweb.com/forums/thread239753.html</link>
			<pubDate>Thu, 19 Nov 2009 13:47:37 GMT</pubDate>
			<description><![CDATA[Hi there, 
 
here what my problem is - I'm trying to get data from MySQL database put in on global array and make calculation. The data in the MySQL table is 3000 rows and 2 columns. The type of data is double and date  
 
Here is the code: 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
here what my problem is - I'm trying to get data from MySQL database put in on global array and make calculation. The data in the MySQL table is 3000 rows and 2 columns. The type of data is double and date <br />
<br />
Here is the code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdlib.h&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;mysql.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
MYSQL conn;<br />
MYSQL_RES *res;<br />
MYSQL_ROW msq_row;<br />
<br />
int main()<br />
{<br />
<br />
&nbsp; &nbsp; double mysql_result[3000][2];<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; int j;<br />
&nbsp; &nbsp; int history=3000;<br />
<br />
&nbsp; <br />
&nbsp; &nbsp; mysql_init(&amp;conn);<br />
&nbsp; &nbsp; mysql_real_connect(&amp;conn, &quot;localhost&quot;, &quot;root&quot;, &quot;1a2s3d&quot;, &quot;portfolio&quot;, 0, NULL, 0);<br />
<br />
&nbsp; &nbsp; mysql_query(&amp;conn, &quot;SELECT date, close from quotes where companyID=1&quot;);<br />
<br />
&nbsp; &nbsp; res=mysql_use_result(&amp;conn);<br />
<br />
&nbsp; <br />
<br />
&nbsp; &nbsp; for (j=0;j=history;j++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i=0;i=mysql_num_fields(res);i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msq_row=mysql_fetch_row(res);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mysql_result[3000][2]=msq_row;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\n&quot;,msq_row[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; mysql_free_result(res);<br />
&nbsp; &nbsp; mysql_close(&amp;conn);<br />
&nbsp; &nbsp;  <br />
<br />
<br />
&nbsp; &nbsp; return (EXIT_SUCCESS);<br />
}</pre><br />
the cygwin g++ compiler give this:<br />
<br />
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf<br />
make[1]: Entering directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/pordotovka.exe<br />
make[2]: Entering directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
mkdir -p build/Debug/Cygwin-Windows<br />
rm -f build/Debug/Cygwin-Windows/main.o.d<br />
g++    -c -g -MMD -MP -MF build/Debug/Cygwin-Windows/main.o.d -o build/Debug/Cygwin-Windows/main.o main.cpp<br />
main.cpp: In function `int main()':<br />
<span style="text-decoration:underline"><span style="color:Red">main.cpp:45: error: cannot convert `char**' to `double' in assignment</span></span><br />
make[2]: *** [build/Debug/Cygwin-Windows/main.o] Error 1<br />
make[2]: Leaving directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
make[1]: *** [.build-conf] Error 2<br />
make[1]: Leaving directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
make: *** [.build-impl] Error 2<br />
BUILD FAILED (exit value 2, total time: 828ms)<br />
<br />
Please give me gleam ... thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>spekulanta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239753.html</guid>
		</item>
		<item>
			<title>Asyncronous Overlapped structure problem (using HttpwaitforDisconnect)</title>
			<link>http://www.daniweb.com/forums/thread239706.html</link>
			<pubDate>Thu, 19 Nov 2009 10:59:26 GMT</pubDate>
			<description>Hello guys, I am having trouble getting an asyncronous communications set up using overlapping. Actually to be more specific I am having problems with using httpWaitForDisconnect to work as async. 
Using the code below I am able to enter the function, but it is in a blocking state which defeats all...</description>
			<content:encoded><![CDATA[<div>Hello guys, I am having trouble getting an asyncronous communications set up using overlapping. Actually to be more specific I am having problems with using httpWaitForDisconnect to work as async.<br />
Using the code below I am able to enter the function, but it is in a blocking state which defeats all the purposes of me trying to use this function in the first place.<br />
The Code:<br />
<br />
 <pre style="margin:20px; line-height:13px">HANDLE hQueue;<br />
HTTP_REQUEST* pHttpData;<br />
ULONG ulReturn = 0;<br />
<br />
OVERLAPPED* ovlp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ZeroMemory(&amp;ovlp, sizeof(&amp;ovlp));<br />
ulReturn = HttpReceiveHttpRequest(hQueue, RequestId, 0, pHttpData, dwBufferSize, &amp;dwSizeReceived, ovlp);<br />
RequestId = pHttpData-&gt;RequestId;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ulReturn == ERROR_INVALID_PARAMETER)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;HttpReceiveHttpRequest : Invalid Parameter&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;Going into the disconnect&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ulReturn = HttpWaitForDisconnect(hQueue, pHttpData-&gt;ConnectionId, ovlp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(ulReturn)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case NO_ERROR:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;User Has Disconnected...&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case ERROR_IO_PENDING:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;IO Pending, next request not ready...&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case ERROR_INVALID_PARAMETER:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;Error&quot; + getLastError());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</pre><br />
Thank you in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>JenniLei</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239706.html</guid>
		</item>
		<item>
			<title><![CDATA[Compiler skips "cin.get();"]]></title>
			<link>http://www.daniweb.com/forums/thread239691.html</link>
			<pubDate>Thu, 19 Nov 2009 09:44:15 GMT</pubDate>
			<description><![CDATA[this is a simple example of a problem I have been having with differing programs, i am using linux ubuntu 9.10 and codeblocks 8.02 .  
 
this is the code   <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>this is a simple example of a problem I have been having with differing programs, i am using linux ubuntu 9.10 and codeblocks 8.02 . <br />
<br />
this is the code  <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
int main()<br />
{<br />
&nbsp; &nbsp; int hiya;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;hello world \n&quot;;<br />
&nbsp; &nbsp; cin.get();<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;enter a number \n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;hiya;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;you entered \n&quot;&lt;&lt; hiya;<br />
&nbsp; &nbsp; cin.get();<br />
}</pre><br />
it compiles but show an error message &quot;warning GDB: Failed to set controlling terminal: operation not permitted&quot;<br />
<br />
then the program runs<br />
<br />
when it gets to the last cin instead of waiting for some input it exits</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>duke.tim</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239691.html</guid>
		</item>
		<item>
			<title>Help</title>
			<link>http://www.daniweb.com/forums/thread239683.html</link>
			<pubDate>Thu, 19 Nov 2009 08:38:31 GMT</pubDate>
			<description>Problem Statement: File Handling in C/C++ 
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen 
A college has announced the total budget of 50,000Rs.for each game. Games are done four times in a year. Take...</description>
			<content:encoded><![CDATA[<div>Problem Statement: File Handling in C/C++<br />
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen<br />
A college has announced the total budget of 50,000Rs.for each game. Games are done four times in a year. Take expenses as an input from user. <br />
Calculate the average expenses for a game:<br />
<br />
<br />
<br />
<br />
<br />
1.	If the expenses greater than 80% show as” Very Expensive”.<br />
2.	If the expenses  are greater than 60% and less than 80% than show “Expensive ”<br />
3.	If the expenses  are greater than 50% and less than 60% than show “Less Expensive ”<br />
4.	If the expenses are greater than 40% and less than 50% than show “Not Costly”.<br />
5.	If the expenses are less than 40% than show “Best”.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ihtesham4deni</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239683.html</guid>
		</item>
		<item>
			<title>complex number</title>
			<link>http://www.daniweb.com/forums/thread239643.html</link>
			<pubDate>Thu, 19 Nov 2009 04:51:11 GMT</pubDate>
			<description><![CDATA[the program is ok(i think)but the data is fixed.i want it able to input your own data.i tried cin>>c1.real>>c1.image; 
                                   cin>>c2.real>>c2.image; 
but it cannot use them because they are private... 
 
 
#include<iostream> 
using namespace std; 
class complex 
{...]]></description>
			<content:encoded><![CDATA[<div>the program is ok(i think)but the data is fixed.i want it able to input your own data.i tried cin&gt;&gt;c1.real&gt;&gt;c1.image;<br />
                                   cin&gt;&gt;c2.real&gt;&gt;c2.image;<br />
but it cannot use them because they are private...<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream&gt;<br />
using namespace std;<br />
class complex<br />
{<br />
public:<br />
<br />
complex(){real=0;image=0;}<br />
<br />
complex(double r,double i){real=r;image=i;}<br />
<br />
complex complex_add(complex &amp;c2);<br />
<br />
complex complex_sub(complex &amp;c2);<br />
<br />
complex complex_mult(complex &amp;c2);<br />
<br />
complex complex_div(complex &amp;c2);<br />
void display();<br />
<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; double real;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double image;<br />
};<br />
<br />
<br />
complex complex::complex_add(complex &amp;c2)<br />
{<br />
complex c;<br />
<br />
c.real=real+c2.real;<br />
<br />
c.image=image+c2.image;<br />
<br />
return c;<br />
}<br />
<br />
complex complex::complex_sub(complex &amp;c2)<br />
<br />
{<br />
&nbsp;complex d;<br />
<br />
d.real=real-c2.real;<br />
<br />
d.image=image-c2.image;<br />
<br />
return d;<br />
}<br />
<br />
complex complex::complex_mult(complex &amp;c2)<br />
{<br />
complex f;<br />
<br />
f.real=real*c2.real;<br />
<br />
f.image=image*c2.image;<br />
<br />
return f;<br />
}<br />
<br />
complex complex::complex_div(complex &amp;c2)<br />
{<br />
&nbsp;complex g;<br />
&nbsp;g.real=real/c2.real;<br />
&nbsp;g.image=image/c2.image;<br />
&nbsp;return g;<br />
}<br />
<br />
<br />
void complex::display()<br />
{<br />
&nbsp; cout&lt;&lt;&quot;(&quot;&lt;&lt;real&lt;&lt;&quot;,&quot;&lt;&lt;image&lt;&lt;&quot;i)&quot;&lt;&lt;endl;<br />
}<br />
<br />
<br />
int main()<br />
{<br />
complex c1(2,5),c2(4,9),c3;&nbsp; //i want input my own complex number.<br />
c3=c1.complex_add(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1+c2=&quot;;c3.display();<br />
<br />
c3=c1.complex_sub(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1-c2=&quot;;c3.display();<br />
<br />
c3=c1.complex_mult(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1*c2=&quot;;c3.display();<br />
<br />
c3=c1.complex_div(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1/c2=&quot;;c3.display();<br />
<br />
return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nick30266</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239643.html</guid>
		</item>
		<item>
			<title>Class Composition Confusion</title>
			<link>http://www.daniweb.com/forums/thread239639.html</link>
			<pubDate>Thu, 19 Nov 2009 04:24:46 GMT</pubDate>
			<description><![CDATA[Today was my first time trying composition. It's for a lab project due Friday, and I have a lot of tomorrow to work on it. However, up until we have just been using one class per program. Now, my teacher wants us to use composition and arrays, despite only lecturing on them for a few minutes....]]></description>
			<content:encoded><![CDATA[<div>Today was my first time trying composition. It's for a lab project due Friday, and I have a lot of tomorrow to work on it. However, up until we have just been using one class per program. Now, my teacher wants us to use composition and arrays, despite only lecturing on them for a few minutes. Worse, there is no section on composition (and arrays in compositions) in our notes/textbook. So, could you check this code and tell me if I'm on the right track. I don't even need help with syntactical errors (yet); I just need an idea of what I need to do, and what I'm not understanding about composition. <br />
<br />
There are five files, and an input file. And the program (as you can see from the input file) reads the student info and stores it in an array and then outputs (1) all information in a table, (2) a student searched by last name, (3) lowest gpa student information, (4) highest units gpa information.<br />
<br />
Thank you very much.<br />
<br />
student.h<br />
 <pre style="margin:20px; line-height:13px"> #ifndef student_H<br />
#define student_H<br />
<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
class Student{<br />
&nbsp; &nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_Name(string, string);&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool readStudent(ifstream &amp;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void printStudent () const;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Student();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string get_Last();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string get_First();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_Major(string);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string get_Major( );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_Units(int);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_GPA(float);<br />
&nbsp; &nbsp; &nbsp; &nbsp; private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; First, Last;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Units;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; GPA;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; &nbsp; &nbsp; &nbsp; Major; <br />
};<br />
<br />
#endif</pre><br />
Student Implementation<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &quot;student.h&quot;<br />
<br />
using namespace std;<br />
void Student::set_Name(string first, string last){<br />
&nbsp; &nbsp; &nbsp; &nbsp; First = first;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Last = last ;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
bool Student::readStudent(ifstream &amp; fin){<br />
&nbsp; &nbsp; &nbsp; &nbsp; getline(fin, First);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (fin){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  getline(fin, Last);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getline(fin, Major);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin &gt;&gt; Units ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin &gt;&gt; GPA ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.ignore(10,'\n');<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return (fin.good());<br />
}<br />
void Student::printStudent () const<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;\n\tStudent information:\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Name:&nbsp;  \t&quot; &lt;&lt; Last +&quot;, &quot;+ First &lt;&lt;endl ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Major:&nbsp; \t&quot; &lt;&lt; Major &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Units : \t&quot;&lt;&lt; Units &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;GPA:&nbsp; &nbsp; \t&quot; &lt;&lt; GPA &lt;&lt; endl &lt;&lt;endl;<br />
}<br />
<br />
Student::Student(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; Units = 0 ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPA = 0 ;<br />
};<br />
string Student::get_Last(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return Last; <br />
}<br />
<br />
void Student::set_Major(string t_major){<br />
&nbsp; &nbsp; &nbsp; &nbsp; Major = t_major;<br />
}<br />
int Student::get_Units(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return Units;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
float Student::get_GPA(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return GPA;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
string Student::get_First(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return First ;<br />
}<br />
string Student::get_Major( ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return Major ;<br />
}<br />
void Student::set_Units(int units){<br />
&nbsp; &nbsp; &nbsp; &nbsp; Units = units ;<br />
}<br />
void Student::set_GPA(float gpa){<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPA = gpa ;<br />
}</pre><br />
school.h<br />
 <pre style="margin:20px; line-height:13px"> #ifndef school_H<br />
#define school_H<br />
#define SIZE 15<br />
<br />
#include &lt;string&gt;<br />
#include &quot;student.h&quot;<br />
<br />
using namespace std;<br />
<br />
class School{<br />
&nbsp; &nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int read_list(Student list[], int size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool open_file(ifstream &amp;fin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void print_list(Student list[], int size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int search(Student list[], int);&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int low_GPA(Student list[], int);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int high_Units(Student list[], int);<br />
&nbsp; &nbsp; &nbsp; &nbsp; private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Student CS101[SIZE];<br />
};<br />
<br />
#endif</pre><br />
School Implementation<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &quot;school.h&quot;<br />
<br />
using namespace std;<br />
int School::search(Student list[], int size){<br />
&nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; &nbsp; &nbsp; &nbsp; target;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;\nPlease enter last name of student to locate:(all lower case) &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; getline(cin, target);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (target.length()&gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target[0] = toupper(target[0]); // convert first character to lower case<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((int)(list[i].get_Last()).find(target)&gt;=0 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return i ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;No name was entered.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return -1 ;&nbsp; // Student was not found on the list;<br />
}<br />
<br />
int School::read_list(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream fin ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool&nbsp; &nbsp; &nbsp; &nbsp; flag ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0 ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (open_file(fin))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = list[i].readStudent(fin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(flag &amp;&amp; !fin.eof())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i &lt; size)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = list[i].readStudent(fin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&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; cout &lt;&lt;&quot;\n*********** Array is full.\n&quot;;<br />
&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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return i ;<br />
}<br />
<br />
bool School::open_file(ifstream &amp;fin)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; f_name ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter = 3 ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool&nbsp; &nbsp; &nbsp; &nbsp; flag = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = true ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Please enter input file name: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getline(cin, f_name) ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.open(f_name.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (fin.fail())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter-- ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;\nBad file name, you have &quot;&lt;&lt; counter &lt;&lt; &quot; chances, try again.\n&quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.clear();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp; false ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while (!flag &amp;&amp; counter &gt;= 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return flag ;<br />
}<br />
void School::print_list(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (size &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;endl &lt;&lt;endl&lt;&lt;left&lt;&lt; setprecision(2) &lt;&lt;showpoint&lt;&lt;fixed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(50)&lt;&lt; &quot;Name&quot;&lt;&lt;setw(30)&lt;&lt;&quot;Major&quot;&lt;&lt;setw(12)&lt;&lt;&quot;Units&quot;&lt;&lt;&quot;GPA\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setfill('-') &lt;&lt; setw(100)&lt;&lt;&quot;-&quot; &lt;&lt; setfill(' ')&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(50)&lt;&lt;list[i].get_Last() + &quot;, &quot; + list[i].get_First() &lt;&lt; setw(30) &lt;&lt; list[i].get_Major();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(12) &lt;&lt; list[i].get_Units() &lt;&lt; list[i].get_GPA() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;endl &lt;&lt;endl &lt;&lt; &quot;****** end of report ******\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
int School::low_GPA(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int lowIndex;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float first, second, lowGPA = 5.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(size &gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = list[i].CS101.get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; second = list[i+1].CS101.get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (first &lt; lowGPA &amp;&amp; first &gt; 0.00){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowIndex = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowGPA = list[i].CS101.get_GPA();<br />
&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; if (second &lt; lowGPA &amp;&amp; second &gt; 0.00){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowIndex = (i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowGPA = list[i+1].CS101.get_GPA();<br />
&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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return lowIndex;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
int School::high_Units(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int first, second, highIndex, highUnits = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(size &gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = list[i].CS101.get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; second = list[i+1].CS101.get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (first &gt; highUnits){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highIndex = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highUnits = list[i].CS101.get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&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; if (second &gt; highUnits){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highIndex = (i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highUnits = list[i+1].CS101.get_Units();<br />
&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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return highIndex;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
Main/Driver <br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &quot;student.h&quot;<br />
#include &quot;school.h&quot;<br />
#define SIZE 15<br />
using namespace std;<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Student CS101[SIZE];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int size, index;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream fin;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; size = CS101.read_list(CS101, SIZE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; CS101.print_list(CS101,size);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(size &gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = CS101.search(CS101, size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (index != -1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You searched for: &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS101[index].printStudent();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Student is not on the list.\n&quot; ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = CS101.low_GPA(CS101, size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (index != -1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The student with the lowest GPA is: &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS101[index].printStudent();&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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = CS101.high_Units(CS101, size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (index != -1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The student with the highest number of units is: &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS101[index].printStudent();&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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; fin.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
Input File: student.txt<br />
 <pre style="margin:20px; line-height:13px">Joe<br />
Smith Jr.<br />
Electrical Engineering<br />
45 3.45<br />
Nancy Karen<br />
Brown<br />
Industrial Engineering<br />
34 4.0<br />
Adam<br />
Jonhson<br />
Computer Science<br />
56 3.89<br />
Gorden<br />
Khalbandy<br />
Mechanical Engineering<br />
89 3.28<br />
Alan<br />
Jackson<br />
Computer Science<br />
34 3.95</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>swolll</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239639.html</guid>
		</item>
		<item>
			<title>Reading char strings and int data from text file</title>
			<link>http://www.daniweb.com/forums/thread239634.html</link>
			<pubDate>Thu, 19 Nov 2009 04:16:36 GMT</pubDate>
			<description><![CDATA[I'm writing a program that is supposed to be able to bubble sort data by name and by average. The data I'm given is student last name followed by 3 scores, all put into a text document. I'm to read the names and scores into their respective parallel arrays, and get the averages of the scores for...]]></description>
			<content:encoded><![CDATA[<div>I'm writing a program that is supposed to be able to bubble sort data by name and by average. The data I'm given is student last name followed by 3 scores, all put into a text document. I'm to read the names and scores into their respective parallel arrays, and get the averages of the scores for each student put into a 3rd and final array. Looks like this:<br />
 <pre style="margin:20px; line-height:13px">Lastname 90 91 92<br />
Lastname 80 81 82</pre><br />
This is the code I have for the read function:<br />
 <pre style="margin:20px; line-height:13px">int read(char filename[], char names[][30], int scores[][3], double averages[])<br />
{<br />
&nbsp; &nbsp; int sum = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // the base of finding the average<br />
&nbsp; &nbsp; int numStu = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // how many students we will have<br />
&nbsp; &nbsp; int col = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // column for names<br />
&nbsp; &nbsp; // read text document<br />
&nbsp; &nbsp; ifstream infile(filename);&nbsp; &nbsp; &nbsp; // define<br />
&nbsp; &nbsp; infile.open(filename);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // open<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for (int i = 0; i &lt; 100; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; infile.getline(names[i], 30, ' ');&nbsp; // get the name, stop when white space is found<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (! names == 'z')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // no names start with lowercase 'z'<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; 4; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile &gt;&gt; scores[i][j]; // start plugging in scores<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += scores[i][j];&nbsp; &nbsp; // while we're at it, get the sum of the scores<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; averages[i] = sum / 3.0;&nbsp; &nbsp; // get the average for this name&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; numStu = i;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; infile.close();&nbsp; &nbsp; &nbsp; &nbsp;  // close<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; return numStu;<br />
}</pre><br />
<br />
This is the code for my write function (outfile stuff in comments because I'm trying to make this work with screen output first):<br />
 <pre style="margin:20px; line-height:13px">void write(char filename[], ios::openmode, char description[], char names[][30], int scores[][3], double averages[], int numberOfStud)<br />
{<br />
&nbsp; &nbsp; // write to text file<br />
&nbsp; &nbsp; // ofstream outfile(filename, mode); // define<br />
&nbsp; &nbsp; cout &lt;&lt; description &lt;&lt; endl;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for (int i = 0; i &lt; numberOfStud; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; names[i] &lt;&lt; ' ';&nbsp; &nbsp; &nbsp; &nbsp;  // print the name<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; fixed &lt;&lt; setw(7) &lt;&lt; setprecision(2) &lt;&lt; averages[i] &lt;&lt; ' ';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // then the averages<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; 4; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; scores[i][j] &lt;&lt; ' '; // then the three exam scores<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;&nbsp;  // then go to the next line<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; // outfile.close();<br />
}</pre><br />
I'm having a problem with garbage output. It comes up with long lines of irrational numbers, intersparsed with many 0's. I'm not sure what I'm missing here. I think the problem is located in the read function.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>muffinhead</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239634.html</guid>
		</item>
		<item>
			<title>Finding maximum in a 10x20 2D array using rand()</title>
			<link>http://www.daniweb.com/forums/thread239631.html</link>
			<pubDate>Thu, 19 Nov 2009 04:01:16 GMT</pubDate>
			<description><![CDATA[I am currently stuck on part a of this problem. I am having a problem with my stub, I am also running this on visual C++ 2008 express. My stub is a program i had to create to find the maximum value from the 10x20 array. For some reason that's not setting up right. I will post y errors the compiler...]]></description>
			<content:encoded><![CDATA[<div>I am currently stuck on part a of this problem. I am having a problem with my stub, I am also running this on visual C++ 2008 express. My stub is a program i had to create to find the maximum value from the 10x20 array. For some reason that's not setting up right. I will post y errors the compiler gave me, but my compiler also don't least lines for whatever reason. so the errors may not make sense, but i'll point them out as carefully as possible.<br />
<br />
okay the official problem states this: <br />
<br />
A. Write a function named findmax() that finds and displays the maximum values<br />
in a two dimensional array of integers. The array should be declared as a 10 row<br />
by 20 column array of integers in main() and populated with random numbers<br />
between 0 and 100.<br />
<br />
B. Modify the function written above so that it also displays the row and column<br />
numbers of the element with the maximum value.<br />
<br />
Here's what I have so far: <br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;ctime&gt;<br />
#include &lt;cstdlib&gt;<br />
using namespace std;<br />
<br />
int findMax(int[][20]);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int j = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int k = 20;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i,u;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int max;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int grade[j][k];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; srand(time(NULL));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;j;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(u=0;u&lt;k;u++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grade[i][u]=rand()%100;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(4) &lt;&lt; grade[i][u];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  findMax(grade);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;The max value is &quot; &lt;&lt; max;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
int findMax(int grade[][20])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i, u;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int j = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int k = 20;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int max = 0;<br />
&nbsp;for(i=0;i&lt;j; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(u=0; u&lt;k; u++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  { if (max &lt; grade[i][u])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; max = max+grade[i][u];<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return max;<br />
}</pre><br />
New Errors:<br />
<br />
Run-Time Check Failure #3 - The variable 'max' is being used without being initialized.<br />
<br />
So After the changes were made, the stub runs, but for some reason it isn't return my max to the int main. When I have it set to cout the maximum value it says the variable max wasn't initialized with a value.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jinjishu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239631.html</guid>
		</item>
		<item>
			<title>crazy internet problem</title>
			<link>http://www.daniweb.com/forums/thread239620.html</link>
			<pubDate>Thu, 19 Nov 2009 02:53:59 GMT</pubDate>
			<description><![CDATA[Long story short, I'm using curl to download a file off my site. I've done tests and successfully downloaded a few txt files. 
 
The main point, though, is to download an exe file. So I uploaded the exe file to my site, and downloaded it straight from my browser with no problems, and the exe ran...]]></description>
			<content:encoded><![CDATA[<div>Long story short, I'm using curl to download a file off my site. I've done tests and successfully downloaded a few txt files.<br />
<br />
The main point, though, is to download an exe file. So I uploaded the exe file to my site, and downloaded it straight from my browser with no problems, and the exe ran fine. But when I tried downloading it with the curl program, it downloaded, yet exe was corrupt and crashed on start. <br />
<br />
Any ideas from you smart guys? my theory is maybe its not downloading it binary-wise or something confusing like that. Any solutions? Thanks<br />
<br />
<br />
<br />
<br />
Code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;curl/curl.h&gt;<br />
#include &lt;cstdio&gt;<br />
&nbsp;<br />
void get_page( const char* url, const char* file_name )<br />
{<br />
&nbsp; CURL* easyhandle = curl_easy_init() ;<br />
&nbsp;<br />
&nbsp; curl_easy_setopt( easyhandle, CURLOPT_URL, url ) ;<br />
&nbsp;<br />
&nbsp; std::FILE* file = std::fopen( file_name, &quot;w&quot; ) ;<br />
&nbsp; curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file ) ;<br />
&nbsp;<br />
&nbsp; curl_easy_perform( easyhandle );<br />
&nbsp;<br />
&nbsp; curl_easy_cleanup( easyhandle );<br />
}<br />
&nbsp;<br />
int main()<br />
{<br />
&nbsp; get_page( &quot;http://*********.com/game.exe&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;testfile.exe&quot; ) ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; system(&quot;PAUSE&quot;);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mybluehair</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239620.html</guid>
		</item>
		<item>
			<title><![CDATA[CHAR[] Help?]]></title>
			<link>http://www.daniweb.com/forums/thread239618.html</link>
			<pubDate>Thu, 19 Nov 2009 02:32:41 GMT</pubDate>
			<description><![CDATA[Hello, i need help with a basic code issue, i ave posted the code here (http://turt2live.zxq.net/cpp/hoomin.html) because it is too long to post... 
 
The issue occurs in this section of code: 
...(more before) 
void getInput(int num){ 
     char = one[1]; 
     char = two[1]; 
     char =...]]></description>
			<content:encoded><![CDATA[<div>Hello, i need help with a basic code issue, i ave posted the code <a rel="nofollow" class="t" href="http://turt2live.zxq.net/cpp/hoomin.html" target="_blank">here</a> because it is too long to post...<br />
<br />
The issue occurs in this section of code:<br />
...(more before)<br />
void getInput(int num){<br />
     char = one[1];<br />
     char = two[1];<br />
     char = three[1];<br />
     char = four[1];<br />
<br />
...(more after)<br />
<br />
saying it is expecting something before the keyword &quot;char&quot; <br />
i am using Dev C++(Latest) as a compiler, and yes, i had i as the following at one point:<br />
<br />
char[5]xxx;<br />
<br />
((Example Variable))<br />
<br />
Any and all help is appreciated. <br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>turtlez</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239618.html</guid>
		</item>
		<item>
			<title>Set return issue with templated set.</title>
			<link>http://www.daniweb.com/forums/thread239612.html</link>
			<pubDate>Thu, 19 Nov 2009 01:51:54 GMT</pubDate>
			<description><![CDATA[Hey guys, 
 
I have this code snippet: 
 
template <typename ElementType, typename CompareClass> 
struct Delegate { 
	virtual bool geef(const ElementType &element){ 
		pair <set<ElementType, CompareClass>::iterator, bool> ret;  //this is line 196 
		ret = elements.insert(element); //197 
		return...]]></description>
			<content:encoded><![CDATA[<div>Hey guys,<br />
<br />
I have this code snippet:<br />
 <pre style="margin:20px; line-height:13px">template &lt;typename ElementType, typename CompareClass&gt;<br />
struct Delegate {<br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual bool geef(const ElementType &amp;element){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pair &lt;set&lt;ElementType, CompareClass&gt;::iterator, bool&gt; ret;&nbsp; //this is line 196<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ret = elements.insert(element); //197<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (ret.second); //198<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual void output() = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; set&lt;ElementType, CompareClass&gt; elements;<br />
};<br />
<br />
struct ArtiestenPrinter : public Delegate&lt;Lied, LiedCompare&gt; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual bool geef(const Lied &amp;lied){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool nieuwElement = Delegate&lt;Lied, LiedCompare&gt;::geef(lied); // 210<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (nieuwElement) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; lied.artiest;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return nieuwElement;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual void output(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(set&lt;Lied, LiedCompare&gt;::iterator it = elements.begin();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; it != elements.end();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; it++){<br />
&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; cout &lt;&lt; it-&gt;artiest &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
};</pre><br />
Which gives me these errors:<br />
 <pre style="margin:20px; line-height:13px">196: error: type/value mismatch at argument 1 in template parameter list for 'template&lt;class _T1, class _T2&gt; struct std::pair'<br />
196: error:&nbsp;  expected a type, got 'std::set&lt;ElementType,CompareClass,std::allocator&lt;_CharT&gt; &gt;::iterator'<br />
196: error: invalid type in declaration before ';' token<br />
198: error: request for member 'second' in 'ret', which is of non-class type 'int'<br />
210:&nbsp;  instantiated from here<br />
197: error: cannot convert 'std::pair&lt;std::_Rb_tree_const_iterator&lt;Lied&gt;, bool&gt;' to 'int' in assignment</pre><br />
I can't get my head around why the compiler is complaining, so any help is greatly appreciated.<br />
<br />
Thanks in advance,</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Clockowl</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239612.html</guid>
		</item>
		<item>
			<title>Need a task.. i can give reward for who solve this to me</title>
			<link>http://www.daniweb.com/forums/thread239603.html</link>
			<pubDate>Thu, 19 Nov 2009 00:56:17 GMT</pubDate>
			<description>ok.. its really hard and takes time and knowlage of C++.. 
i hope i am in the right section for this.. if no please the mods move it to the right one.. 
 
Whoever manage to make over it... is god for me. i can  give one premium rs account valid til 23 Octomber 2010 if anyone can make this.. please...</description>
			<content:encoded><![CDATA[<div>ok.. its really hard and takes time and knowlage of C++..<br />
i hope i am in the right section for this.. if no please the mods move it to the right one..<br />
<br />
Whoever manage to make over it... is god for me. i can  give one premium rs account valid til 23 Octomber 2010 if anyone can make this.. please let me send the rs account only when the compiler runs it..<br />
Its a program i need make at C - C++. it need make RSA algorithm with the following. all you have to do is complete where its empty with the codes of Encryption, Decription and Constraction of keys where it say &quot;==== PUT YOUR FUNCTIONS HERE ====&quot;.<br />
For any questions ask me here..<br />
<br />
here is the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;time.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
<br />
#define MAX_BITS 64 /* Max integer that will have 2^64 - 1 bits */<br />
#define MAX_CHARS 100 /* Max character's number that get readed by fgets() */<br />
#define LENGTH_P 9 /* Lenght of p in decimals */<br />
#define LENGTH_Q 9 /* Lenght of q in decimals */<br />
#define BLOCK_SIZE 8 /* will be cryptographed 8 ASCII characters by section */<br />
<br />
<br />
/* For the constract of keys */<br />
<br />
void NewSeed (void);<br />
long long ModMult(long long a, long long b, long long mod);<br />
int RabinMiller(long long candidate);<br />
long long ModInverse(long long val, long long mod);<br />
<br />
/* For the cryptography */<br />
void GetBlock(char *block, FILE *fp, int numChars);<br />
<br />
<br />
<br />
<br />
int main(int argc, char **argv){<br />
<br />
&nbsp;  <br />
}<br />
<br />
/* ==== PUT YOUR FUNCTIONS HERE ====*/<br />
<br />
<br />
<br />
<br />
/* *********************************************************************** */<br />
/* *********************************************************************** */<br />
<br />
void NewSeed (void){<br />
&nbsp;  srand( (unsigned) time( NULL )); /* Seed = current time. */<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
long long ModMult(long long a, long long b, long long mod){<br />
&nbsp;  /* Perform res = (a * b) % mod, avoiding intermediate overflow */<br />
&nbsp;  long long res = 0;<br />
&nbsp;  long long a1 = a % mod;<br />
&nbsp;  long long b1 = b % mod;<br />
<br />
<br />
&nbsp;  while(b1 != 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(b1 &amp; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  res = (res + a1) % mod;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a1 = (a1 &lt;&lt; 1) % mod;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b1 &gt;&gt;= 1;<br />
&nbsp;  }<br />
&nbsp;  return res;<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
/* Requires stdlib.h */<br />
int RabinMiller(long long candidate){<br />
&nbsp;  long long a, n, d, x, t, rem;<br />
&nbsp;  int i, j;<br />
&nbsp;  /* const int MaxBits = 64; */ /* Allow for a max int of 2^64 - 1 */<br />
&nbsp;  int bits[MAX_BITS];<br />
&nbsp;  int roundFailed = 1; /* Boolean */<br />
<br />
&nbsp;  n = candidate;<br />
<br />
&nbsp;  t = n - 1;<br />
&nbsp;  for(i=0; i&lt;MAX_BITS; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rem = t % 2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(rem == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  bits[i] = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  bits[i] = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(t == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t /= 2;<br />
&nbsp;  }<br />
<br />
&nbsp;  /* Main algorithm starts here */<br />
&nbsp;  for(j=0; j&lt;5; j++){ /* Perform 5 rounds against 5 random bases */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = (2 + (long long) rand()) % (n-1); /* Ensure 1 &lt; a &lt; n-1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- rand() produces smaller than n-1 for large n */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(; i&gt;=0; i--){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  x = d;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  d = ModMult(d, d, n);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(d == 1 &amp;&amp; x != 1 &amp;&amp; x != n - 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roundFailed = 1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(bits[i])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d = ModMult(d, a, n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(d != 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  roundFailed = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  roundFailed = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(roundFailed)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return 0;<br />
&nbsp;  }<br />
&nbsp;  /* If this point has been reached, then the candidate number has passed<br />
&nbsp;  all rounds successfully. */<br />
&nbsp;  return 1;<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
long long ModInverse(long long val, long long mod){<br />
<br />
&nbsp;  long long c1, c2, c3, t, b1, b2, b3;<br />
&nbsp;  int sign = 0;<br />
&nbsp;  c1 = mod;<br />
&nbsp;  c2 = val;<br />
&nbsp;  c3 = 0;<br />
&nbsp;  b1 = 0;<br />
&nbsp;  b2 = 1;<br />
&nbsp;  b3 = 0;<br />
&nbsp;  t = 0;<br />
<br />
&nbsp;  do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = c1 / c2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c3 = c1 % c2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b3 = t * b2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b3 = b1 + b3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c1 = c2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c2 = c3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b1 = b2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b2 = b3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sign++;<br />
&nbsp;  }while(c2 != 0);<br />
<br />
&nbsp;  if(sign % 2 == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b1 = mod - b1;<br />
<br />
&nbsp;  return b1;<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
/*<br />
Reads numChars from file pointer fp and stores them to block.<br />
if there are less than numChars characters, pad out with spaces<br />
*/<br />
void GetBlock(char *block, FILE *fp, int numChars){<br />
&nbsp;  int i = 0, charsRead = 0;<br />
&nbsp;  char c, str[BLOCK_SIZE+1];<br />
<br />
&nbsp;  while((c = fgetc(fp)) != EOF &amp;&amp; i &lt; numChars){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(c == '\n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str[i] = c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp;  }<br />
&nbsp;  charsRead = i;<br />
&nbsp;  if(c != EOF) /* There are more chars in the file, but the block is full */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ungetc(c, fp);<br />
<br />
&nbsp;  if(charsRead &lt; numChars){ /* Need to pad out with blanks */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i=charsRead; i &lt;= numChars; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  str[i] = ' ';<br />
&nbsp;  }<br />
&nbsp;  str[numChars] = '\0'; /* Add string terminator */<br />
&nbsp;  strcpy(block, str);<br />
}<br />
<br />
/* *********************************************************************** */</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>FeVerSeCtioN</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239603.html</guid>
		</item>
		<item>
			<title>Write 4 functions to compute and return</title>
			<link>http://www.daniweb.com/forums/thread239600.html</link>
			<pubDate>Thu, 19 Nov 2009 00:29:04 GMT</pubDate>
			<description><![CDATA[Hi, new learner to C++.  I have to write 4 functions to compute and return the diameter, circumference, etc. of a circle.  I think I might be on the right track but I'm probably making this harder than it has to be.  I commented most code out because I'd like to get one thing working and then go...]]></description>
			<content:encoded><![CDATA[<div>Hi, new learner to C++.  I have to write 4 functions to compute and return the diameter, circumference, etc. of a circle.  I think I might be on the right track but I'm probably making this harder than it has to be.  I commented most code out because I'd like to get one thing working and then go back and finish.  How do I get the radius value into the equation?  When I run it the answer comes up<br />
-1.#IND when I put in a radius of 2.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;cmath&gt;<br />
using namespace std ;<br />
<br />
double radius ;<br />
double diam ;<br />
double const PI = 3.14159265358979323846 ;<br />
<br />
<br />
double diameter(double diam)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; double d ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (d = 2 * radius ) <br />
&nbsp; &nbsp; &nbsp; &nbsp; return d ;<br />
}<br />
<br />
//double circum(double circumf)<br />
//{<br />
//&nbsp; &nbsp; &nbsp; &nbsp; return diam * PI ;<br />
//}<br />
//<br />
//double area(double area1)<br />
//{<br />
//&nbsp; &nbsp; &nbsp; &nbsp; return PI * pow(radius, radius) ;<br />
//}<br />
//<br />
//double volume(double vol1)<br />
//{<br />
//&nbsp; &nbsp; &nbsp; &nbsp; return (4.0/3.0) * (radius * radius * radius) * PI ;<br />
//}<br />
<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; double radius ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the radius of a circle: &quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; radius ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; double d = diameter(diam) ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The diameter of the circle is: &quot; &lt;&lt; d &lt;&lt; endl ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /*circum(circumf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The circumference of the circle is: &quot; &lt;&lt; circumf &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; area(area1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The area of the circle is: &quot; &lt;&lt; area1 &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; volume(vol1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The volume of the sphere is: &quot; &lt;&lt; vol1 &lt;&lt; endl;*/<br />
<br />
<br />
<br />
return 0 ;<br />
<br />
}</pre><br />
Thank you!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>guccitan88</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239600.html</guid>
		</item>
		<item>
			<title>String assigns not permanent</title>
			<link>http://www.daniweb.com/forums/thread239599.html</link>
			<pubDate>Thu, 19 Nov 2009 00:21:34 GMT</pubDate>
			<description>Nevermind.</description>
			<content:encoded><![CDATA[<div>Nevermind.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Clockowl</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239599.html</guid>
		</item>
		<item>
			<title>Arithmetic operations</title>
			<link>http://www.daniweb.com/forums/thread239597.html</link>
			<pubDate>Thu, 19 Nov 2009 00:18:33 GMT</pubDate>
			<description><![CDATA[This program runs perfect just want to know if I have to do this arithmetic operations using functions how can I do that?   
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>This program runs perfect just want to know if I have to do this arithmetic operations using functions how can I do that?  <br />
<br />
 <pre style="margin:20px; line-height:13px">// Arithmetic.cpp - This program performs arithmetic, ( +. -, *. / ) on two numbers.<br />
// Input:&nbsp; Interactive<br />
// Output:&nbsp; Result of arithmetic operation<br />
<br />
#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
int main(int argc, char *argv[]) <br />
{<br />
&nbsp;  double numberOne, numberTwo;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  string operation;<br />
&nbsp;  double result;&nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp;  cout &lt;&lt; &quot;Enter the first number: &quot;;<br />
&nbsp;  cin &gt;&gt; numberOne; <br />
&nbsp;  cout &lt;&lt; &quot;Enter the second number: &quot;;<br />
&nbsp;  cin &gt;&gt; numberTwo; <br />
&nbsp;  cout &lt;&lt; &quot;Enter an operator (+.-.*,/): &quot;;<br />
&nbsp;  cin &gt;&gt; operation;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  if (operation == &quot;+&quot;)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne + numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (operation == &quot;-&quot;)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne - numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (operation == &quot;*&quot;)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne * numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (operation == &quot;/&quot;)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne / numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  } <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; numberOne;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; &quot; &lt;&lt; operation &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; = &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; result &lt;&lt; endl;<br />
<br />
system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
} // End of main() function</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239597.html</guid>
		</item>
		<item>
			<title>Linear and Binary search</title>
			<link>http://www.daniweb.com/forums/thread239595.html</link>
			<pubDate>Thu, 19 Nov 2009 00:02:51 GMT</pubDate>
			<description><![CDATA[Iam trying to code a single program of an array with 20 elements in it. It asks for a number from user and search is if this array has that number. 
 
 I am using Binary and selection search. 
 
Its not giving me the required results. here  is my code; 
 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Iam trying to code a single program of an array with 20 elements in it. It asks for a number from user and search is if this array has that number.<br />
<br />
 I am using Binary and selection search.<br />
<br />
Its not giving me the required results. here  is my code;<br />
<br />
 <pre style="margin:20px; line-height:13px">/* Linear and Binary search<br />
<br />
<br />
*/<br />
<br />
#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
// Function prototype<br />
<br />
int searchList(int [], int , int );<br />
<br />
int binarySearch(int [], int, int);<br />
<br />
&nbsp;const int size = 20;<br />
<br />
int main()<br />
<br />
{<br />
int tests[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};<br />
<br />
&nbsp;int num1, num2;<br />
&nbsp;<br />
int result1, result2;<br />
<br />
//search the array for 19<br />
<br />
result1 = searchList(tests, size ,19);<br />
<br />
<br />
// if searchList&nbsp; returns -1 , then num1 is not found<br />
cout &lt;&lt; &quot;Enter the number you wish to search for: &quot;;<br />
cin &gt;&gt; num1;<br />
&nbsp;  if (result1 == -1)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;There is no num1 &quot;&lt;&lt;endl;<br />
&nbsp;  }<br />
&nbsp;  <br />
&nbsp;  else <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;num1 is found&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt;&quot;and its position is =&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout&lt;&lt; (result1+1)&lt;&lt;endl; <br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp;  }<br />
&nbsp; &nbsp; // calling Function for Binary search<br />
&nbsp; &nbsp; <br />
result2 = binarySearch(tests , size, 19);<br />
&nbsp; &nbsp; <br />
cout &lt;&lt; &quot;Enter the number you wish to search for: &quot;;<br />
cin &gt;&gt; num2;<br />
<br />
&nbsp; &nbsp; &nbsp;  if (result2 == -1)<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;That number does not exist in the array.\n&quot;;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;That ID is found at element &quot; &lt;&lt; result2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; in the array.\n&quot;; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp;  <br />
&nbsp;  <br />
system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; return 0;<br />
}<br />
<br />
/*<br />
**************************************<br />
<br />
&nbsp;void displayList( int [], int)<br />
<br />
&nbsp;{<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;}<br />
<br />
/**********************************************************/<br />
<br />
/*SearchList Function performs a linear search. Array&nbsp; name is list <br />
and it has a max numElem elements . <br />
if the number&nbsp; is found <br />
If the number is found, its array <br />
subscript is returned. Otherwise, -1 is returned. *<br />
****************************************************************<br />
*/<br />
<br />
int searchList(int list [], int numElem, int value)<br />
<br />
{<br />
&nbsp; &nbsp; int index =0 ;<br />
&nbsp; &nbsp; int position = -1;<br />
&nbsp; &nbsp; bool found = false;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; while (index &lt; numElem &amp;&amp; !found)&nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (list [index]== value )&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; found = true ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  position= index;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index++;<br />
&nbsp; &nbsp; }<br />
<br />
return position;<br />
&nbsp; &nbsp; <br />
}<br />
<br />
//********************************************************************<br />
/* The function should keep a count of the<br />
number of comparisons it makes until it finds the value. <br />
<br />
<br />
//***********************************************************************<br />
/* Function for&nbsp; Binary search*/<br />
<br />
int binarySearch(int array[], int numElems, int value)<br />
{<br />
&nbsp; &nbsp; int first = 0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // First array element<br />
&nbsp; &nbsp; &nbsp; &nbsp; last = numElems - 1,&nbsp; &nbsp; // Last array element<br />
&nbsp; &nbsp; &nbsp; &nbsp; middle,&nbsp; &nbsp; &nbsp; &nbsp; // Midpoint of search<br />
&nbsp; &nbsp; &nbsp; &nbsp; position = -1; // Position of search value<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool found = false;&nbsp; &nbsp;  // Flag<br />
<br />
while (!found &amp;&amp; first &lt;= last)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; middle = (first + last) / 2; // Calculate midpoint<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (array[middle] == value) // If value is found at midpoint<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; found = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position = middle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; else if (array[middle] &gt; value) // If value is in lower half<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; last = middle - 1;<br />
&nbsp; &nbsp; }<br />
&nbsp;else<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; first = middle + 1;&nbsp; &nbsp; &nbsp; &nbsp; // If value is in upper half<br />
&nbsp; &nbsp; &nbsp; }<br />
return position;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>rafta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239595.html</guid>
		</item>
		<item>
			<title>Splitting up a string</title>
			<link>http://www.daniweb.com/forums/thread239594.html</link>
			<pubDate>Wed, 18 Nov 2009 23:56:30 GMT</pubDate>
			<description><![CDATA[So, I'm asking a user to input a fraction in the form of this: 
 
+3 3/4 
 
I know I can use a search to find where the first instance of something happens, but how do I actually take whats before it?  Example: I can tell it to search for white space, but how can I tell it to grab what is before it...]]></description>
			<content:encoded><![CDATA[<div>So, I'm asking a user to input a fraction in the form of this:<br />
<br />
+3 3/4<br />
<br />
I know I can use a search to find where the first instance of something happens, but how do I actually take whats before it?  Example: I can tell it to search for white space, but how can I tell it to grab what is before it and save it into a variable?<br />
<br />
 Would it be easier to use an array of characters or can a string work?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>wyett</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239594.html</guid>
		</item>
		<item>
			<title>convert string w spaces to an array w/o spaces</title>
			<link>http://www.daniweb.com/forums/thread239586.html</link>
			<pubDate>Wed, 18 Nov 2009 22:53:12 GMT</pubDate>
			<description><![CDATA[Hi, I am having a user input a series of numbers and characters separated by spaces. like "10 23 65 34 765 34 65 34 64 354  64" and i need to put these into an array without the spaces. I stores them into a string but whenever i do like   <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi, I am having a user input a series of numbers and characters separated by spaces. like &quot;10 23 65 34 765 34 65 34 64 354  64&quot; and i need to put these into an array without the spaces. I stores them into a string but whenever i do like  <pre style="margin:20px; line-height:13px"> mystring[0]</pre> i only get the first digit and not the number. or if i put  <pre style="margin:20px; line-height:13px"> mystring[1]</pre> i only get the second number like in the digits above. i want  <pre style="margin:20px; line-height:13px"> mystring[0]</pre>  to contain 10 and not just 1. <br />
Please help!!!!!!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mampam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239586.html</guid>
		</item>
		<item>
			<title>Lotto array program with void function</title>
			<link>http://www.daniweb.com/forums/thread239570.html</link>
			<pubDate>Wed, 18 Nov 2009 21:52:19 GMT</pubDate>
			<description>I have to write a program that allows a user to pick five numbers from one to 55. The computer will then generate 5 random numbers and determine how many of the users choices match the generated numbers. I have to create an algorithm for this program. The program will have a void function to...</description>
			<content:encoded><![CDATA[<div>I have to write a program that allows a user to pick five numbers from one to 55. The computer will then generate 5 random numbers and determine how many of the users choices match the generated numbers. I have to create an algorithm for this program. The program will have a void function to generate 5 random numbers from one to 55, no duplicate numbers allowed. The random numbers and the choices will be stored in two one dimensional arrays. The program will have a void function to display the random<br />
numbers and the users choices and the number of matches. The program will contain a loop that will generate a new set of random numbers and user choices unless the user tells the program to quit.  I don't even know where to start with this.  The void function is what I'm not getting mostly.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>vinochick</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239570.html</guid>
		</item>
		<item>
			<title>HELP Me Plz</title>
			<link>http://www.daniweb.com/forums/thread239567.html</link>
			<pubDate>Wed, 18 Nov 2009 21:42:51 GMT</pubDate>
			<description>Please 
ok can any one give me the code to this im making a program and it needs this and im stuck please give code asap  
application that will convert any text I throw at it to hex  
Thank You</description>
			<content:encoded><![CDATA[<div>Please<br />
ok can any one give me the code to this im making a program and it needs this and im stuck please give code asap <br />
application that will convert any text I throw at it to hex <br />
Thank You</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ImMoRtAl-</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239567.html</guid>
		</item>
	</channel>
</rss>
