<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>C Board</title>
		<link>http://cboard.cprogramming.com</link>
		<description><![CDATA[Cprogramming.com's message board, filled with helpful programmers.]]></description>
		<language>en</language>
		<lastBuildDate>Fri, 20 Nov 2009 21:43:53 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://cboard.cprogramming.com/images/misc/rss.jpg</url>
			<title>C Board</title>
			<link>http://cboard.cprogramming.com</link>
		</image>
		<item>
			<title>simulating alt+2 (keypad) combination</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121812-simulating-altplus2-keypad-combination.html</link>
			<pubDate>Fri, 20 Nov 2009 21:02:16 GMT</pubDate>
			<description><![CDATA[I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead) 
The following doesn't seem to work. Just prints "2". 
 
 
Code: 
--------- 
keybd_event(VK_MENU,0 ,0 , 0); //Alt Press 
...]]></description>
			<content:encoded><![CDATA[<div>I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead)<br />
The following doesn't seem to work. Just prints &quot;2&quot;.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">keybd_event(VK_MENU,0 ,0 , 0); //Alt Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, 0 , 0); // 2 Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, KEYEVENTF_KEYUP,0); // 2 Release<br />
<br />
Sleep(10);<br />
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); // Alt Release<br />
<br />
Sleep(10);</code><hr />
</div>Neither does this work. Just prints &quot;2&quot;, again.<br />
<br />
	<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">INPUT inputs = {0}; <br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.type = INPUT_KEYBOARD; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; KEYBDINPUT ki = {0}; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_LMENU;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_NUMPAD2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.dwFlags = KEYEVENTF_KEYUP;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_NUMPAD2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ki.wVk = VK_LMENU;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputs.ki = ki;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>kangekraam</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121812-simulating-altplus2-keypad-combination.html</guid>
		</item>
		<item>
			<title>Question about reading in strings and integers</title>
			<link>http://cboard.cprogramming.com/c-programming/121811-question-about-reading-strings-integers.html</link>
			<pubDate>Fri, 20 Nov 2009 20:56:34 GMT</pubDate>
			<description>Hi, 
 
I am reading in strings and integers and I am wondering, am I doing this correctly where I will prevent overflow problems and also not have a bunch of issues with my strings? Since I started messing with C, I have had tremendous problems getting this stuff to work and I think I got it now. I...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am reading in strings and integers and I am wondering, am I doing this correctly where I will prevent overflow problems and also not have a bunch of issues with my strings? Since I started messing with C, I have had tremendous problems getting this stuff to work and I think I got it now. I am just wondering how to improve the code I wrote.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;limits.h&gt;<br />
<br />
void read(char *out, const int size);<br />
int readint(int *out);<br />
void readdouble(double *out);<br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char buffer[17] = {0};<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double d = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;read string[16]: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; read(buffer, 17);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;read integer: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!readint(&amp;i)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;the number you entered is beyond the range allowable, please try again.&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!readint(&amp;i)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;the number you entered is beyond the range allowable, please try again.&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;read: %s\t\t%d\n\n&quot;, buffer, strlen(buffer));<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;readint: %d\n\n&quot;, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;readint: %5.2f\n\n&quot;, d);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; function:&nbsp; &nbsp; &nbsp;  read<br />
&nbsp; &nbsp; &nbsp; &nbsp; purpose:&nbsp; &nbsp; &nbsp; &nbsp; reads in a string and assigns it to out. Requires a length of <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string parameter of n+1 (+1 allows for null terminator).<br />
&nbsp; &nbsp; &nbsp; &nbsp; args:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char *out, const int strlen<br />
&nbsp; &nbsp; &nbsp; &nbsp; returns:&nbsp; &nbsp; &nbsp; &nbsp; void<br />
*/<br />
void read(char *out, const int strlen)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char ch;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int char_count = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Read in the keyboard input until enter is pressed or<br />
&nbsp; &nbsp; &nbsp; &nbsp; // we exceed the buffer. We will not allow the buffer<br />
&nbsp; &nbsp; &nbsp; &nbsp; // to overflow by restricting what actually gets written<br />
&nbsp; &nbsp; &nbsp; &nbsp; // to the pointer.<br />
&nbsp; &nbsp; &nbsp; &nbsp; ch = getchar();<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(out)++ = ch;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(ch != '\n' &amp;&amp; ++char_count &lt; strlen-1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch = getchar();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(char_count &lt; strlen-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *(out)++ = ch;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Null terminate the pointer so it is a proper string<br />
&nbsp; &nbsp; &nbsp; &nbsp; *out = '\0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Flush the remaining keyboard input<br />
&nbsp; &nbsp; &nbsp; &nbsp; fflush(stdin);<br />
}<br />
<br />
/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; function:&nbsp; &nbsp; &nbsp;  readint<br />
&nbsp; &nbsp; &nbsp; &nbsp; purpose:&nbsp; &nbsp; &nbsp; &nbsp; reads an integer and assigns it to the out pointer parameter.<br />
&nbsp; &nbsp; &nbsp; &nbsp; defines:&nbsp; &nbsp; &nbsp; &nbsp; INT_LEN<br />
&nbsp; &nbsp; &nbsp; &nbsp; args:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int *out<br />
&nbsp; &nbsp; &nbsp; &nbsp; returns:&nbsp; &nbsp; &nbsp; &nbsp; int (1 success, -1 error)<br />
*/<br />
#define INT_LEN 100<br />
int readint(int *out)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char buf[INT_LEN];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* buffer for retriving an int */<br />
&nbsp; &nbsp; &nbsp; &nbsp; char tmpbuf[INT_LEN];&nbsp;  /* temporary buffer for reconverting the int to a string to check for integer overflow */<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i, tmpbuflen, buflen;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; read(buf, INT_LEN);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* read input from the user as a string */<br />
&nbsp; &nbsp; &nbsp; &nbsp; i = atoi(buf);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* convert the string to an int */<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Reconvert to a string to ensure that the conversion didn't cause an integer overflow<br />
&nbsp; &nbsp; &nbsp; &nbsp; itoa(i, tmpbuf, 10);<br />
&nbsp; &nbsp; &nbsp; &nbsp; tmpbuflen = strlen(tmpbuf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; buflen = strlen(buf) - 1; /* subtract 1 for the null terminator, otherwise comparison will fail */<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(tmpbuflen != buflen || INT_MIN &lt; i &amp;&amp; i &gt; INT_MAX) // check if they are the same and within signed integer ranges<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; *out = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>sgalland</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121811-question-about-reading-strings-integers.html</guid>
		</item>
		<item>
			<title>Array size set by variable</title>
			<link>http://cboard.cprogramming.com/c-programming/121810-array-size-set-variable.html</link>
			<pubDate>Fri, 20 Nov 2009 20:49:25 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I am having issues compiling a program with cc on a fairly old unix system, I understand that I need to follow C standards strictly but I can find no way around this. 
 
Code: 
--------- 
array(int n) 
{ 
int i; 
int array[n];]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am having issues compiling a program with cc on a fairly old unix system, I understand that I need to follow C standards strictly but I can find no way around this.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">array(int n)<br />
{<br />
int i;<br />
int array[n];<br />
<br />
for(i=0;i&lt;=n-1;i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; array[i]=i+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
}</code><hr />
</div>It is a simple function to setup an array to size n which is collected and passed in from the main function. The compiler is freaking at the array declaration, saying that I have declared an array of 0 and that the expression is not constant, as it compiles line by line and this is the last function I am happy with the rest of my code.<br />
Does anyone have any ideas how I can get around this?<br />
<br />
Thanks</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Drainy</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121810-array-size-set-variable.html</guid>
		</item>
		<item>
			<title>Problem with shared memory</title>
			<link>http://cboard.cprogramming.com/c-programming/121809-problem-shared-memory.html</link>
			<pubDate>Fri, 20 Nov 2009 20:40:44 GMT</pubDate>
			<description>Hi everyone, 
 
I have this problem. 
 
 
Code: 
--------- 
......... 
......... 
open shared memory.....</description>
			<content:encoded><![CDATA[<div>Hi everyone,<br />
<br />
I have this problem.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">.........<br />
.........<br />
open shared memory.....<br />
.........&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; sem_init(&amp;mutex, 0, 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; sem_trywait(&amp;mutex);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (i&lt;n) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int f = fork();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (f==0) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RSA *rsa;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsa = RSA_generate_key(1024 , 65537, NULL, NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr[i].a=BN_bn2hex(rsa-&gt;d);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr[i].b=BN_bn2hex(rsa-&gt;n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
sem_post(&amp;mutex);<br />
<br />
<br />
sem_wait(&amp;mutex);<br />
<br />
int z=0;<br />
while(z&lt;n)<br />
{<br />
printf(&quot;%s\n&quot;,ptr[z].a);<br />
printf(&quot;%s\n&quot;,ptr[z].b);<br />
z++;<br />
}<br />
.........<br />
close shared memory......<br />
.........<br />
.........</code><hr />
</div>when i do printf(ptr[z].a) or printf(ptr[z].b) i don't receive the BN_bn2hex(rsa-&gt;d), but Segmentation Fault.<br />
<br />
Any sugestion to solve this......<br />
Thanks.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>dimaneg</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121809-problem-shared-memory.html</guid>
		</item>
		<item>
			<title>String testing</title>
			<link>http://cboard.cprogramming.com/c-programming/121808-string-testing.html</link>
			<pubDate>Fri, 20 Nov 2009 20:32:26 GMT</pubDate>
			<description><![CDATA[Hello, im trying to design a function that takes in a string, and test it for having 
 
" The first 1/3 (rounding down) of the word's letters is repeated elsewhere in the word. e.g. abracadabra" 
 
I understand the logic of looping through the array, and finding matches, but have been un-able to...]]></description>
			<content:encoded><![CDATA[<div>Hello, im trying to design a function that takes in a string, and test it for having<br />
<br />
&quot; The first 1/3 (rounding down) of the word's letters is repeated elsewhere in the word. e.g. abracadabra&quot;<br />
<br />
I understand the logic of looping through the array, and finding matches, but have been un-able to create a working test that does the above task correctly.<br />
<br />
and help would be greatly appreciated.<br />
<br />
thanks<br />
nailz</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Nailz</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121808-string-testing.html</guid>
		</item>
		<item>
			<title>Arrays and Functions</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121807-arrays-functions.html</link>
			<pubDate>Fri, 20 Nov 2009 20:02:57 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I have created a simple program that will be adding data into a file, but I need to get this part going first. I'm having a problem when trying to add the name of the item. It skips that line and jumps to the next one not letting me to enter the name. Any help on this will be appreciated....]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I have created a simple program that will be adding data into a file, but I need to get this part going first. I'm having a problem when trying to add the name of the item. It skips that line and jumps to the next one not letting me to enter the name. Any help on this will be appreciated.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;cctype&gt;<br />
<br />
#define cMax 100<br />
<br />
using namespace std;<br />
<br />
void invMenu();<br />
void crtNewItem(double Qty[], double iPrice[], char iName[], int pNumber[]);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; int mSelec;<br />
&nbsp; &nbsp; bool bDone = false;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; do{<br />
<br />
cout &lt;&lt; &quot;1. Inventory Management&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;\nPlease enter your selection [1-5]&quot; &lt;&lt; endl;<br />
cin &gt;&gt; mSelec;<br />
while (mSelec &lt; 1&nbsp; || mSelec &gt; 5)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter a correct selection between 1-5&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; mSelec;<br />
}<br />
<br />
switch(mSelec)<br />
{<br />
&nbsp; case 1: invMenu();<br />
&nbsp; break;<br />
<br />
&nbsp;  }<br />
}while (!bDone);<br />
return 0;<br />
<br />
}<br />
<br />
void invMenu()<br />
<br />
&nbsp;{<br />
&nbsp; &nbsp; double Qty[cMax];<br />
&nbsp; &nbsp; double iPrice[cMax];<br />
&nbsp; &nbsp; char iName[cMax];<br />
&nbsp; &nbsp; int pNumber[cMax];<br />
<br />
&nbsp; &nbsp; int iSelec = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;cls&quot;);<br />
<br />
cout &lt;&lt; &quot;\n1. Create New Item&quot; &lt;&lt; endl;<br />
cout &lt;&lt; &quot;\nPlease enter your selection [1-6]&quot; &lt;&lt; endl;<br />
cin &gt;&gt; iSelec;<br />
while (iSelec &lt; 1&nbsp; || iSelec &gt; 6)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter a correct selection. [1-6]&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; iSelec;<br />
}<br />
<br />
switch(iSelec)<br />
{<br />
&nbsp; &nbsp; case 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //This calls out the fuction to create a new item.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; crtNewItem(Qty,iPrice,iName,pNumber);<br />
&nbsp; &nbsp; break;<br />
}<br />
<br />
&nbsp;}<br />
<br />
void crtNewItem(double Qty[], double iPrice[], char iName[], int pNumber[])<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;cls&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ofstream outputFile;<br />
<br />
&nbsp;outputFile.open(&quot;InvItems.txt&quot;, ios::app);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the quantity of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; Qty[cMax];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the name of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin.getline(iName, cMax);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the part number of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; pNumber[cMax];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the price of the item:__&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; iPrice[cMax];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputFile &lt;&lt; Qty[cMax] &lt;&lt; setw(10) &lt;&lt; iName[cMax] &lt;&lt; setw(10) &lt;&lt; pNumber[cMax] &lt;&lt; setw(10) &lt;&lt; iPrice[cMax] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputFile.close();<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n************************************************&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\nYou have just added a new item to the inventory!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n************************************************&quot; &lt;&lt; endl &lt;&lt; endl;<br />
}</code><hr />
</div>Any advice on how to solve this will be appreciated. Thanks!</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>drkidd22</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121807-arrays-functions.html</guid>
		</item>
		<item>
			<title>CPU increase with precomputed tables?</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121806-cpu-increase-precomputed-tables.html</link>
			<pubDate>Fri, 20 Nov 2009 19:44:58 GMT</pubDate>
			<description><![CDATA[(edit: I'm done editing now, I promise. Maybe.) 
 
The problem is that using precomputed tables results in higher CPU usage and that's confusing me. The routine which creates the table is in fact occurring outside of the applications render loop. It is NOT being recomputed every iteration. 
 
So...]]></description>
			<content:encoded><![CDATA[<div>(edit: I'm done editing now, I promise. Maybe.)<br />
<br />
The problem is that using precomputed tables results in higher CPU usage and that's confusing me. The routine which creates the table is in fact occurring outside of the applications render loop. It is NOT being recomputed every iteration.<br />
<br />
So here are the details;<br />
<br />
I've designed a class which executes some numerical algorithms and I've added some methods which allow user to specify the location to some precomputed tables to speed things up.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">vector&lt; vector&lt; float &gt; &gt; *TCOS, *TSIN;<br />
//...<br />
void ALG::UseTrigTables(vector&lt; vector&lt; float &gt; &gt; *fsin, vector&lt; vector&lt; float &gt; &gt; *fcos)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; TCOS = fcos;<br />
&nbsp; &nbsp; &nbsp; &nbsp; TSIN = fsin;<br />
}</code><hr />
</div>After the object is created I will attach the tables like so;<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">vector&lt; vector&lt; float &gt; &gt;<br />
&nbsp;tcos(N, vector&lt; float &gt; (N)),<br />
&nbsp;tsin(N, vector&lt; float &gt; (N));<br />
<br />
// [insert loop here to fill vector-vectors with data]... etc...<br />
<br />
Blah.UseTrigTables(&amp;fsin, &amp;fcos)</code><hr />
</div>Within the class the tables are used like so;<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">float f0;<br />
for (int k = 0; k &lt; N; ++k)<br />
for (int j = 0; j &lt; N; ++j)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; f0 = fA[k] * fB[j] * (*TSIN)[k][j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; // ...<br />
}</code><hr />
</div>Why would that increase CPU usage?<br />
<br />
With trig: ~8%<br />
With tables: ~10%<br />
<br />
Where N = 128  (size of tables/loop)<br />
<br />
My first guess;<br />
<br />
While I am passing a pointer, maybe I'm missing something critical and the tables are actually being copied to a new location in memory every time i call them??<br />
<br />
If not, what exact tools do you recommend I use to profile this applications behavior?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>since</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121806-cpu-increase-precomputed-tables.html</guid>
		</item>
		<item>
			<title>Counting Pixels In A Blob</title>
			<link>http://cboard.cprogramming.com/c-programming/121805-counting-pixels-blob.html</link>
			<pubDate>Fri, 20 Nov 2009 19:44:17 GMT</pubDate>
			<description><![CDATA[The purpose of the program is to take a position and count how many "pixels" are in the "blob". If there is no "pixel" aka the value is 0, the blob number is 0. If there is a pixel, the blob_check function recursively checks the surrounding cells for "pixels" aka values of 1. My program compiles...]]></description>
			<content:encoded><![CDATA[<div>The purpose of the program is to take a position and count how many &quot;pixels&quot; are in the &quot;blob&quot;. If there is no &quot;pixel&quot; aka the value is 0, the blob number is 0. If there is a pixel, the blob_check function recursively checks the surrounding cells for &quot;pixels&quot; aka values of 1. My program compiles but doesn't accurately count the number of pixels in the blob. If I ask it to count the number of pixels in the blob for (0,0) it gives a 4 instead of a 5. Please help!<br />
<br />
<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
#define N 5<br />
<br />
int blob_check(int pic[N][N], int x, int y)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (pic[x][y] == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pic[x][y] = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int sum = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //check <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x-1, y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x-1, y+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (y&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x, y+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x+1, y+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (x&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x+1, y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x+1, y-1);<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; else if (y&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x, y-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x-1, y-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return sum;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x,y,i,j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int row=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line[80];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int table[N][N] = { {1,1,0,0,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; {0,1,1,0,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; {0,0,1,0,1},<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; {1,0,0,0,1},<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; {0,1,0,1,1}};<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\t0\t1\t2\t3\t4\t&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&nbsp;  -----------------------------------------&quot;);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;5;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&nbsp;  |\n%d&nbsp; |\t&quot;, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(j=0;j&lt;5;j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\t&quot;, table[i][j]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&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; <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; printf(&quot;\n\nEnter x-y coordinates of cell&nbsp; =&gt; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d %d&quot;, &amp;y, &amp;x);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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; printf(&quot;Pixel quantity in blob: %i\n&quot;, blob_check(table, x, y));<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>cokacola</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121805-counting-pixels-blob.html</guid>
		</item>
		<item>
			<title>String with two words: 1)String, 2)  $double</title>
			<link>http://cboard.cprogramming.com/c-programming/121804-string-two-words-1-string-2-%24double.html</link>
			<pubDate>Fri, 20 Nov 2009 19:10:05 GMT</pubDate>
			<description><![CDATA[I have a string saved in memory with exactly one space in the middle and two substrings; the string is formatted like this: 
 
"Mike $120.00" 
 
The first word will be saved as a string, the second needs to be converted to a float.  Please, how can I do separate this string at the space and convert...]]></description>
			<content:encoded><![CDATA[<div>I have a string saved in memory with exactly one space in the middle and two substrings; the string is formatted like this:<br />
<br />
&quot;Mike $120.00&quot;<br />
<br />
The first word will be saved as a string, the second needs to be converted to a float.  Please, how can I do separate this string at the space and convert the 2nd string into a float?<br />
<br />
Thanks in advance.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Roger</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121804-string-two-words-1-string-2-%24double.html</guid>
		</item>
		<item>
			<title>help</title>
			<link>http://cboard.cprogramming.com/tech-board/121803-help.html</link>
			<pubDate>Fri, 20 Nov 2009 18:33:22 GMT</pubDate>
			<description>just 1na 2 know if I can I install 2003 visual studio.net on windows vista and if work..? 
ty all...</description>
			<content:encoded><![CDATA[<div>just 1na 2 know if I can I install 2003 visual studio.net on windows vista and if work..?<br />
ty all...</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/tech-board/">Tech Board</category>
			<dc:creator>Carzon</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/tech-board/121803-help.html</guid>
		</item>
		<item>
			<title>Basic operator overloading question</title>
			<link>http://cboard.cprogramming.com/cplusplus-programming/121802-basic-operator-overloading-question.html</link>
			<pubDate>Fri, 20 Nov 2009 18:04:22 GMT</pubDate>
			<description><![CDATA[Hi there, 
 
I'm just starting to try out Operator Overloading and wrote a basic definition for the equality operator ==. 
 
*base.h :* 
 
Code: 
--------- 
class Base 
{]]></description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
I'm just starting to try out Operator Overloading and wrote a basic definition for the equality operator ==.<br />
<br />
<b>base.h :</b><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">class Base<br />
{<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Base (int a);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int getNo() const { return m_a; }<br />
<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; int m_a;<br />
};<br />
Base::Base(int a)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; m_a = a;<br />
<br />
}<br />
bool operator==(const Base&amp; leftparameter, const&nbsp; Base&amp; rightparameter)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; leftparameter.getNo() == rightparameter.getNo();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return true;<br />
}</code><hr />
</div><b><br />
main.cpp :</b><br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;iostream&gt;<br />
#include &quot;base.h&quot;<br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Base obj1(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Base obj2(1);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(obj1 == obj2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Objects match&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Objects don't match&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; system (&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</code><hr />
</div>Just a basic query, Visual Studio reports:<br />
<br />
<div style="margin:20px; margin-top:5px; ">
	<div class="smallfont" style="margin-bottom:2px">Quote:</div>
	<table cellpadding="1" cellspacing="0" border="0" width="100%">
	<tr>
		<td class="alt2">
			<hr />
			
				warning C4553: '==' : operator has no effect; did you intend '='?
			
			<hr />
		</td>
	</tr>
	</table>
</div>I'm just wondering why it says == has no effect when it does successfully compare the two objects. <br />
I don't see why would it think I meant to assign one object to another.<br />
<br />
Should I not worry about it? Or am I missing the point of the warning?<br />
<br />
Thanks for any info!</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/cplusplus-programming/">C++ Programming</category>
			<dc:creator>Swerve</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/cplusplus-programming/121802-basic-operator-overloading-question.html</guid>
		</item>
		<item>
			<title>OpenAL sources limit</title>
			<link>http://cboard.cprogramming.com/game-programming/121801-openal-sources-limit.html</link>
			<pubDate>Fri, 20 Nov 2009 17:56:30 GMT</pubDate>
			<description>Hello! 
My computer game uses OpenAL. I have recently encountered a problem: I can not generate as many sources as I want. It gives me this error: 
 
Code: 
--------- 
There are not enough non-memory resources to create all the requested sources, or the array pointer is not valid. 
--------- 
I...</description>
			<content:encoded><![CDATA[<div>Hello!<br />
My computer game uses OpenAL. I have recently encountered a problem: I can not generate as many sources as I want. It gives me this error:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">There are not enough non-memory resources to create all the requested sources, or the array pointer is not valid.</code><hr />
</div>I don't actually understand what they mean by &quot;non-memory resources&quot;. What does the count of possible sources depend on? How can I detect the possible count of sources? Some computers seem to allow much more sources.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/game-programming/">Game Programming</category>
			<dc:creator>moment</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/game-programming/121801-openal-sources-limit.html</guid>
		</item>
		<item>
			<title>C and RS232 problem</title>
			<link>http://cboard.cprogramming.com/linux-programming/121800-c-rs232-problem.html</link>
			<pubDate>Fri, 20 Nov 2009 16:39:55 GMT</pubDate>
			<description><![CDATA[Hi all, 
 
I'm in troubles in writing C drivers for a device using RS232 port. 
I cannot establish any communications between my linux box and that device! On the other hand I'm sure the RS232 on the device is working properly because using a hyperterminal on another Windows machine everything...]]></description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I'm in troubles in writing C drivers for a device using RS232 port.<br />
I cannot establish any communications between my linux box and that device! On the other hand I'm sure the RS232 on the device is working properly because using a hyperterminal on another Windows machine everything works fine.<br />
<br />
Here is what is reported in the manual of the device:<br />
<br />
&quot;The RS232 communication parameters are:<br />
9600 BAUD, 8 BIT, NO PARITY, 1 STOP BIT (8N1)<br />
...<br />
Each command is an ASCII string, and must be terminated by a Carriage Return character[...] The responses are terminated by a Carriage Return character.&quot;<br />
<br />
Here is my code:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;unistd.h&gt;<br />
#include &lt;fcntl.h&gt;<br />
#include &lt;termios.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
int open_port(char *port)<br />
{<br />
<br />
&nbsp; int fd;<br />
&nbsp; if (!port)<br />
&nbsp; &nbsp; return -1;<br />
&nbsp; if ((fd=open(port,O_RDWR | O_NOCTTY | O_NDELAY))&lt;0)<br />
&nbsp; &nbsp; return -2;<br />
&nbsp; fcntl(fd,F_SETFL,0);<br />
&nbsp; return fd;<br />
}<br />
<br />
void configure_port(int fd)<br />
{<br />
&nbsp; struct termios newtio;<br />
&nbsp; bzero(&amp;newtio,sizeof(newtio));<br />
&nbsp; newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD ;<br />
&nbsp; newtio.c_iflag = IGNPAR | ICRNL;<br />
&nbsp; newtio.c_oflag=0;<br />
&nbsp; newtio.c_lflag=ICANON;<br />
&nbsp; tcflush(fd,TCIFLUSH);<br />
&nbsp; tcsetattr(fd,TCSANOW,&amp;newtio);<br />
}<br />
<br />
int main (int argc, char **argv)<br />
{<br />
&nbsp; int fd;<br />
&nbsp; char PORT[]=&quot;/dev/ttyUSB0&quot;;<br />
&nbsp; int status;<br />
&nbsp; char buffer[255];<br />
<br />
&nbsp; if ((fd=open_port(PORT))&lt;0)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;Error in opening serial port fd=%d\n&quot;,fd);<br />
&nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; configure_port(fd);<br />
<br />
&nbsp; if ((status=write(fd,&quot;SE\r&quot;,3))&lt;3)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;Error in writing on serial port\n&quot;);<br />
&nbsp; &nbsp; &nbsp; return -1;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp;  status=read(fd,buffer,255);<br />
&nbsp;  buffer[status]=0;<br />
&nbsp;  printf(&quot;:%s:%d\n&quot;,buffer,status);<br />
&nbsp;  return 0;<br />
}</code><hr />
</div>This code is compiled without any errors or warnings but unfortunately I cannot read correct values from the device (the device should respond 2 digits ASCII<br />
code terminated with Carriage Return character to the command SE).<br />
In particular sometimes it happens to read &quot;SE\r&quot; (so exactly the same command I write on the RS232 from the pc) and in some other cases the read values are wrong in format and in length.<br />
I cannot figure out where the problem is. I guess it is a rs232 configuration problem because as I told you using hyperterminal on Windows everything is ok but I really did not realize what is going wrong.<br />
Maybe the problem is that I'm using a serial to usb converter and it needs further configuration I'm missing? (The same converter works with hyperterminal).<br />
By the way here is the output of my linux box when I plug in the converter:<br />
<br />
usb 2-1: new full speed USB device using uhci_hcd and address 13<br />
usb 2-1: configuration #1 chosen from 1 choice<br />
pl2303 2-1:1.0 pl2303 converter detected<br />
usb 2-1: pl2303 converter now attached to ttyUSB0<br />
<br />
Any suggestions?<br />
<br />
Any help is really appreciated.<br />
<br />
Thank you for your attention.<br />
<br />
Bye</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/linux-programming/">Linux Programming</category>
			<dc:creator>gda</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/linux-programming/121800-c-rs232-problem.html</guid>
		</item>
		<item>
			<title>C Escape sequences</title>
			<link>http://cboard.cprogramming.com/c-programming/121799-c-escape-sequences.html</link>
			<pubDate>Fri, 20 Nov 2009 15:06:47 GMT</pubDate>
			<description><![CDATA[Apart from \n and \t escape sequnces, which escape sequences can be written into code and be "invisible" to the user? 
 
For example; 
char a=' 
' 
 
In between the ' ' is a \n when the program reads it. How about other Escapes? Can i find them on the keyboard? 
 
For example \r, \v etc...]]></description>
			<content:encoded><![CDATA[<div>Apart from \n and \t escape sequnces, which escape sequences can be written into code and be &quot;invisible&quot; to the user?<br />
<br />
For example;<br />
char a='<br />
'<br />
<br />
In between the ' ' is a \n when the program reads it. How about other Escapes? Can i find them on the keyboard?<br />
<br />
For example \r, \v etc...<br />
<br />
The reason im asking this is because im writing a syntax checker in C and i want to know which escape sequences count more then 1 blank, and are they all writtable by keyboard.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Tool</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121799-c-escape-sequences.html</guid>
		</item>
		<item>
			<title>Bison/Yacc shift/reduce reduce/reduce</title>
			<link>http://cboard.cprogramming.com/tech-board/121798-bison-yacc-shift-reduce-reduce-reduce.html</link>
			<pubDate>Fri, 20 Nov 2009 14:15:12 GMT</pubDate>
			<description>problem solved - cant find delete button for post</description>
			<content:encoded><![CDATA[<div>problem solved - cant find delete button for post</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/tech-board/">Tech Board</category>
			<dc:creator>AnthonyGould</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/tech-board/121798-bison-yacc-shift-reduce-reduce-reduce.html</guid>
		</item>
	</channel>
</rss>
