<?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>Tech support, programming, web development, and internet marketing community. Forums to get free computer help and support.</description>
		<language>en-US</language>
		<lastBuildDate>Sun, 06 Jul 2008 06:50:36 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/forums/myimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - C++</title>
			<link>http://www.daniweb.com/forums</link>
		</image>
		<item>
			<title>template problem</title>
			<link>http://www.daniweb.com/forums/thread132883.html</link>
			<pubDate>Sun, 06 Jul 2008 06:38:13 GMT</pubDate>
			<description><![CDATA[The following code is a minimal example of what I am trying to do.  When I compiled it with
Visual C++ 2008 Express, I got the error:

main.cpp(62) : error C2677: binary '*' : no global operator found which takes type 'Point<T>' (or there is no acceptable conversion)
1>        with
1>        [
1>  ...]]></description>
			<content:encoded><![CDATA[<div>The following code is a minimal example of what I am trying to do.  When I compiled it with<br />
Visual C++ 2008 Express, I got the error:<br />
<br />
main.cpp(62) : error C2677: binary '*' : no global operator found which takes type 'Point&lt;T&gt;' (or there is no acceptable conversion)<br />
1&gt;        with<br />
1&gt;        [<br />
1&gt;            T=float<br />
1&gt;        ]<br />
1&gt;        main.cpp(68) : see reference to function template instantiation 'void   foo&lt;float,double&gt;(T,T,T)' being compiled<br />
1&gt;        with<br />
1&gt;        [<br />
1&gt;            T=float<br />
1&gt;        ]<br />
<br />
<b>However</b>,  if I change foo so that it does not take any parameter, the error will be gone.<br />
<br />
Could anyone tell me where I am wrong?  Thanks <br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1">template&lt;class T&gt;</div></li><li class="li1"><div class="de1">class Point <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">private:</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; T x, y, z;</div></li><li class="li2"><div class="de2">public:</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Point<span class="br0">&#40;</span>T xx, T yy, T zz<span class="br0">&#41;</span> : x<span class="br0">&#40;</span>xx<span class="br0">&#41;</span>, y<span class="br0">&#40;</span>yy<span class="br0">&#41;</span>, z<span class="br0">&#40;</span>zz<span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; template&lt;class U&gt; operator Point&lt;U&gt; <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw4">const</span> <span class="br0">&#123;</span> <span class="kw1">return</span> Point&lt;U&gt;<span class="br0">&#40;</span> U<span class="br0">&#40;</span>x<span class="br0">&#41;</span>, U<span class="br0">&#40;</span>y<span class="br0">&#41;</span>, U<span class="br0">&#40;</span>z<span class="br0">&#41;</span> <span class="br0">&#41;</span>; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span>;</div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">template&lt;class T&gt;</div></li><li class="li1"><div class="de1">class Matrix<span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">private:</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; T m<span class="br0">&#91;</span><span class="nu0">16</span><span class="br0">&#93;</span>;</div></li><li class="li2"><div class="de2">public:</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Matrix<span class="br0">&#40;</span>T x, T y, T z<span class="br0">&#41;</span><span class="br0">&#123;</span><span class="br0">&#125;</span>&nbsp; &nbsp; &nbsp; &nbsp; </div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Point&lt;T&gt; operator* <span class="br0">&#40;</span><span class="kw4">const</span> Point&lt;T&gt;&amp; p<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">return</span> Point&lt;T&gt;<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">0</span>,<span class="nu0">0</span><span class="br0">&#41;</span>; <span class="br0">&#125;</span> </div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span>;</div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1"><span class="coMULTI">/* this does not work */</span></div></li><li class="li1"><div class="de1">template&lt;class T, class C&gt;</div></li><li class="li1"><div class="de1"><span class="kw4">void</span> foo<span class="br0">&#40;</span>T x, T y, T z<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; Point&lt;T&gt; o1<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">0</span>,<span class="nu0">0</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; Matrix&lt;C&gt; m<span class="br0">&#40;</span>C<span class="br0">&#40;</span>x<span class="br0">&#41;</span>,C<span class="br0">&#40;</span>y<span class="br0">&#41;</span>, C<span class="br0">&#40;</span>z<span class="br0">&#41;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; m * o1;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2"><span class="coMULTI">/*but this does work</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">template&lt;class T, class C&gt;</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">void foo()</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">{</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp; &nbsp; &nbsp; &nbsp; Point&lt;T&gt; o1(0,0,0);</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">&nbsp; &nbsp; &nbsp; &nbsp; Matrix&lt;C&gt; m(C(1),C(1), C(1));</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp; &nbsp; &nbsp; &nbsp; m * o1;</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">}</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">*/</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; foo&lt;float,double&gt;<span class="br0">&#40;</span><span class="nu0">1</span>,<span class="nu0">1</span>,<span class="nu0">1</span><span class="br0">&#41;</span>; <span class="co1">// failed</span></div></li><li class="li1"><div class="de1"><span class="co1">//&nbsp; &nbsp; &nbsp; foo&lt;float,double&gt;();&nbsp; works</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="nu0">0</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></code> </div></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>yifli</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132883.html</guid>
		</item>
		<item>
			<title>desktop icons</title>
			<link>http://www.daniweb.com/forums/thread132870.html</link>
			<pubDate>Sun, 06 Jul 2008 03:37:58 GMT</pubDate>
			<description>hi 
i have an icon with atransparent background that i want to assign to an MFC dialog based application
but the problem is that this icon appears to have a white background .... how to make it transparent ......
pleeease help</description>
			<content:encoded><![CDATA[<div>hi <br />
i have an icon with atransparent background that i want to assign to an MFC dialog based application<br />
but the problem is that this icon appears to have a white background .... how to make it transparent ......<br />
pleeease help</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>lahom</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132870.html</guid>
		</item>
		<item>
			<title>Size of array passed as parameter.</title>
			<link>http://www.daniweb.com/forums/thread132852.html</link>
			<pubDate>Sat, 05 Jul 2008 21:26:49 GMT</pubDate>
			<description>I need to find the number of elements in an array passed into a function. The problem is in this case, sizeof() returns the size of the pointer itself. It only does this when passed through to a function. So here is that function:

bool matchWord(TWORD *wordList, TWORD *word, char *str)
{
	for(int...</description>
			<content:encoded><![CDATA[<div>I need to find the number of elements in an array passed into a function. The problem is in this case, sizeof() returns the size of the pointer itself. It only does this when passed through to a function. So here is that function:<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1">bool matchWord<span class="br0">&#40;</span>TWORD *wordList, TWORD *word, <span class="kw4">char</span> *str<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span><span class="kw4">int</span> i = <span class="nu0">0</span>; i &lt; <span class="kw4">sizeof</span><span class="br0">&#40;</span>wordList<span class="br0">&#41;</span> / <span class="kw4">sizeof</span><span class="br0">&#40;</span>wordList<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span>; i++<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>_stricmp<span class="br0">&#40;</span>wordList<span class="br0">&#91;</span>i<span class="br0">&#93;</span>-&gt;str, str<span class="br0">&#41;</span> == <span class="nu0">0</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; word-&gt;str = wordList<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">str</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; word-&gt;id = wordList<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">id</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; word-&gt;pos = wordList<span class="br0">&#91;</span>i<span class="br0">&#93;</span>.<span class="me1">pos</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></code> </div>
Here is the array definition if you need to look at it:<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1">TWORD *wordList = new TWORD<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>;</div></li><li class="li1"><div class="de1">wordList<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">setValues</span><span class="br0">&#40;</span><span class="st0">&quot;move&quot;</span>, WORD_MOVE, POS_VERB, <span class="nu0">-1</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">wordList<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>.<span class="me1">setValues</span><span class="br0">&#40;</span><span class="st0">&quot;north&quot;</span>, WORD_NORTH, POS_NOUN, <span class="nu0">-1</span><span class="br0">&#41;</span>;</div></li></ol></pre></code> </div>
And although you really shouldn't need to look at is for this problem, here is the definition of the TWORD class:<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1">class TWORD</div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public:</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">char</span> *str;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> id;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> pos;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> index;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TWORD<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TWORD<span class="br0">&#40;</span><span class="kw4">char</span> *str, <span class="kw4">int</span> id, <span class="kw4">int</span> pos, <span class="kw4">int</span> index<span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">void</span> setValues<span class="br0">&#40;</span><span class="kw4">char</span> *str, <span class="kw4">int</span> id, <span class="kw4">int</span> pos, <span class="kw4">int</span> index<span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">char</span> *posToString<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">char</span> *toString<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span>;</div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">TWORD::<span class="me2">TWORD</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;str = <span class="kw2">NULL</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;id = <span class="nu0">0</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;pos = <span class="nu0">0</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;index = <span class="nu0">-1</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">TWORD::<span class="me2">TWORD</span><span class="br0">&#40;</span><span class="kw4">char</span> *str, <span class="kw4">int</span> id, <span class="kw4">int</span> pos, <span class="kw4">int</span> index<span class="br0">&#41;</span></div></li><li class="li2"><div class="de2"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;str = str;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;id = id;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;pos = pos;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;index = index;</div></li><li class="li2"><div class="de2"><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw4">void</span> TWORD::<span class="me2">setValues</span><span class="br0">&#40;</span><span class="kw4">char</span> *str, <span class="kw4">int</span> id, <span class="kw4">int</span> pos, <span class="kw4">int</span> index<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;str = str;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;id = id;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;pos = pos;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; this-&gt;index = index;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2"><span class="kw4">char</span> *TWORD::<span class="me2">posToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">switch</span><span class="br0">&#40;</span>this-&gt;pos<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> POS_NOUN:</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="st0">&quot;noun&quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw2">break</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> POS_VERB:</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="st0">&quot;verb&quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw2">break</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="st0">&quot;unknown&quot;</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw4">char</span> *TWORD::<span class="me2">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">char</span> *str = new <span class="kw4">char</span><span class="br0">&#91;</span><span class="nu0">100</span><span class="br0">&#93;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; sprintf<span class="br0">&#40;</span>str, <span class="st0">&quot;String: %s<span class="es0">\n</span>ID: %d<span class="es0">\n</span>Pos: %s<span class="es0">\n</span>Index: %d<span class="es0">\n</span>&quot;</span>, this-&gt;str, this-&gt;id, this-&gt;posToString<span class="br0">&#40;</span><span class="br0">&#41;</span>, this-&gt;index<span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> str;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></code> </div>
Please don't suggest the vector template, I usually stick to straight C and this is about as far away from that as I am really willing to get.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>death_oclock</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132852.html</guid>
		</item>
		<item>
			<title>Could someone please assist me with a GCD program I am working on?</title>
			<link>http://www.daniweb.com/forums/thread132817.html</link>
			<pubDate>Sat, 05 Jul 2008 14:59:29 GMT</pubDate>
			<description>Hello all. I am new to the board and hope to build great relationships with other forum members. I am working on a program for class that is supposed to show the GCD. I used a text editor to make it, but when i put it in Visual express 2008, it keeps showing error messages, when I thought I did it...</description>
			<content:encoded><![CDATA[<div>Hello all. I am new to the board and hope to build great relationships with other forum members. I am working on a program for class that is supposed to show the GCD. I used a text editor to make it, but when i put it in Visual express 2008, it keeps showing error messages, when I thought I did it properly. Can anyone show me what I did wrong so I can make it work in visual? Thank you very much<br />
<br />
/*******************************************************/<br />
/*  File: name of your file with the source code       */<br />
/*                                                     */<br />
/* Created by: give your  name                         */<br />
/* Date: give the date                                 */<br />
/*                                                     */<br />
/* Program to compute the GCD of two integers          */<br />
/*                                                     */<br />
/* Inputs: (keyboard)                                  */<br />
/* 1. Two numbers - only positive numbers allowed       */<br />
/*                                                     */<br />
/* Output:                                             */<br />
/* Print the GCD of given numbers on the screen        */<br />
/*                                                     */<br />
/* Algorithm: Euclid's Algorithm                       */<br />
/*                                                     */<br />
/*******************************************************/<br />
<br />
#include &quot;stdafx.h&quot; <br />
#include &lt;iostream&gt;<br />
<br />
using namespace std ;<br />
<br />
int main()<br />
{<br />
<br />
    Declare x, y, temp, remainder as Integer.<br />
	int x;<br />
	int	y;<br />
	int	temp<br />
	int	remainder = 1;<br />
<br />
    // read in the two integers<br />
<br />
    cout &lt;&lt; endl ;<br />
    cout &lt;&lt; &quot;Enter the first number (positive integer) : &quot; ;<br />
    cin &gt;&gt; x ;<br />
    cout &lt;&lt; &quot;Enter the second number (positive integer) : &quot; ;<br />
    cin &gt;&gt; y ;<br />
<br />
    //echo inputs<br />
<br />
    cout &lt;&lt; &quot;Input numbers are: &quot; &lt;&lt; x &lt;&lt; &quot; , &quot; &lt;&lt; y &lt;&lt; endl ;<br />
<br />
    Write a C++ if statement to determine if x &lt; y.<br />
<br />
    if ((x == 0) || (y == 0))<br />
    {<br />
		cout &lt;&lt; &quot;ERROR:  Value of 0 has been entered.&quot;<br />
		return (-1);<br />
	}<br />
<br />
    if (x &lt; y)<br />
    { // exchange values of x and y<br />
    	temp = x;<br />
    	x = y;<br />
    	y = temp;<br />
    }<br />
<br />
    /* At this point we will always have x &gt;= y */<br />
<br />
<br />
    Initialize remainder.<br />
<br />
    while ( remainder != 0  )<br />
        {<br />
            Write the loop expression and loop body code in C++.<br />
            In C++, the expression (x % y) gives the remainder<br />
            after dividing x by y.<br />
<br />
            // value of q<br />
            temp = x / y;<br />
<br />
            // value of r<br />
            remainder = x % y;<br />
<br />
            // replace x with y<br />
            x = y;<br />
<br />
            // replace y with remainder<br />
            y = remainder;<br />
<br />
        }<br />
<br />
    // display the result<br />
    cout &lt;&lt; endl ;<br />
    cout &lt;&lt; &quot;The GCD is: &quot; &lt;&lt; y &lt;&lt; endl ;<br />
<br />
    return (0); // terminate with success<br />
}</div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums//forums/myimages/attach/cpp.gif" alt="File Type: cpp" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=6527&amp;d=1215269860">GCD project.cpp</a> (2.4 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>akeem923</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132817.html</guid>
			<enclosure url="http://www.daniweb.com/forums/attachment.php/6527/GCD+project.cpp" length="2456" type="unknown/unknown" />
		</item>
		<item>
			<title>Having troubles with variables and array...</title>
			<link>http://www.daniweb.com/forums/thread132802.html</link>
			<pubDate>Sat, 05 Jul 2008 11:57:30 GMT</pubDate>
			<description>I am writing a payroll program with inheritance for a school assignment that has the following requirments: 

*Expand the Employee Payroll program to include hourly based and salary based employees. This phase uses an array of employee objects, inheritance for different classes of employees, and...</description>
			<content:encoded><![CDATA[<div>I am writing a payroll program with inheritance for a school assignment that has the following requirments: <br />
<br />
<b>Expand the Employee Payroll program to include hourly based and salary based employees. This phase uses an array of employee objects, inheritance for different classes of employees, and polymorphism for salary computation. The 52 week yearly salary as well as number of overtime hours worked by a salary based employee is given). For salary based employees, to find the regular (gross) pay for a week, divide the salary by 52. To compute the overtime pay for a salary based employee, first find the hourly rate by dividing the gross pay by 40, and then compute overtime pay. For every employee, overtime pay, tax amount, and net pay must also be computed. In addition, the program should find the minimum and maximum net pay of all employees as well as sort the employees based on their net pay (ascending order).</b><br />
<br />
This is my code:<br />
<br />
  <div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1"><span class="co2">#include&lt;fstream&gt;</span></div></li><li class="li1"><div class="de1"><span class="co2">#include&lt;iostream&gt;</span></div></li><li class="li1"><div class="de1"><span class="co2">#include&lt;iomanip&gt;</span></div></li><li class="li1"><div class="de1"><span class="kw2">using</span> <span class="kw2">namespace</span> std;</div></li><li class="li2"><div class="de2"><span class="kw2">class</span> payroll<span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; ifstream fin;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw2">public</span>: string employeename;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">char</span> paystat;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">int</span> n;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw4">float</span> taxrate;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">double</span> hoursworked, overtimehours, regularhours;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">double</span> hourlyrate,regularpay,totalnetpay,minnp,maxnp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">double</span> avgnetpay,taxamount,netpay,grosspay,overtimepay;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw2">virtual</span> <span class="kw4">double</span> findgrosspay<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw4">void</span> setvariables<span class="br0">&#40;</span><span class="kw4">char</span><span class="br0">&#91;</span><span class="br0">&#93;</span>,<span class="kw4">int</span>,<span class="kw4">char</span>,<span class="kw4">char</span>,<span class="kw4">char</span>,<span class="kw4">double</span>,<span class="kw4">double</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw2">virtual</span> <span class="kw4">double</span> findtaxamount<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw2">virtual</span> <span class="kw4">double</span> findnetpay<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw2">virtual</span> <span class="kw4">double</span> findavgnetpay<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">void</span> printheaders<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw4">void</span> printdata<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">double</span> minnet<span class="br0">&#40;</span><span class="kw4">double</span>, <span class="kw4">int</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">double</span> maxnet<span class="br0">&#40;</span><span class="kw4">double</span>, <span class="kw4">int</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">void</span> printminmax<span class="br0">&#40;</span><span class="kw4">double</span>, <span class="kw4">double</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">void</span> printreport<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw4">void</span> sortbypointers<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; payroll<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; ~payroll<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp; <span class="kw2">class</span> hourly: <span class="kw2">public</span> payroll<span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="kw2">public</span>: <span class="kw4">double</span> findgrosspay<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="kw1">if</span><span class="br0">&#40;</span>hoursworked &gt; <span class="nu0">40</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  overtimehours=hoursworked<span class="nu0">-40</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  regularpay=hoursworked*hourlyrate;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;  overtimepay=overtimehours*<span class="br0">&#40;</span>hourlyrate*<span class="nu0">1.5</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  grosspay=regularpay+overtimepay;<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="kw1">else</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  grosspay=hoursworked*hourlyrate;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  regularpay=grosspay;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;  <span class="kw1">return</span> grosspay;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//IF</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>;<span class="co1">//findgrosspay</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw2">class</span> salaried:<span class="kw2">public</span> payroll<span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span>: <span class="kw4">double</span> findgrosspay<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="kw1">if</span><span class="br0">&#40;</span>hoursworked&gt;<span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp;  </div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  overtimepay=hoursworked*<span class="br0">&#40;</span>regularpay/<span class="nu0">52</span>/<span class="nu0">40</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  regularpay=hourlyrate/<span class="nu0">52</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  grosspay=regularpay+overtimepay; </div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;  <span class="kw1">return</span> grosspay;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//If </span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span>;<span class="co1">//findgrosspay</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span>;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;  payroll::<span class="me2">payroll</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  fin.<span class="me1">open</span><span class="br0">&#40;</span><span class="st0">&quot;salariedemployees.in&quot;</span><span class="br0">&#41;</span>; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  payroll::~payroll<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  fin.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<span class="br0">&#125;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">double</span> payroll::<span class="me2">findtaxamount</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp;  taxrate=.<span class="nu0">30</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  taxamount=grosspay*taxrate;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">return</span> taxamount;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//findtaxamount</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp; <span class="kw4">double</span> payroll::<span class="me2">findnetpay</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  netpay=grosspay-taxamount;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  totalnetpay=totalnetpay+netpay;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="kw1">return</span> netpay;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//findnetpay&nbsp; </span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">double</span> payroll::<span class="me2">findavgnetpay</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  avgnetpay=totalnetpay/n;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;endl&lt;&lt;<span class="st0">&quot;The average net pay for &quot;</span>&lt;&lt;n&lt;&lt;<span class="st0">&quot; employees is &quot;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;setprecision<span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span>&lt;&lt;fixed&lt;&lt;left&lt;&lt;showpoint&lt;&lt;avgnetpay&lt;&lt;endl;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">return</span> avgnetpay;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//findavgnetpay&nbsp; &nbsp; </span></div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">double</span> payroll::<span class="me2">minnet</span><span class="br0">&#40;</span><span class="kw4">double</span> minnp, <span class="kw4">int</span> n<span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">if</span><span class="br0">&#40;</span>n==<span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minnp=<span class="nu0">1000000</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">if</span><span class="br0">&#40;</span>netpay&lt;minnp<span class="br0">&#41;</span> <span class="br0">&#123;</span>minnp=netpay;<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;endl&lt;&lt;<span class="st0">&quot;The minimum net pay for &quot;</span>&lt;&lt;n&lt;&lt;<span class="st0">&quot; employees is&quot;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;setprecision<span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span>&lt;&lt;fixed&lt;&lt;left&lt;&lt;showpoint&lt;&lt;minnp&lt;&lt;endl;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">return</span> minnp;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//minnet</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">double</span> payroll::<span class="me2">maxnet</span><span class="br0">&#40;</span><span class="kw4">double</span> maxnp, <span class="kw4">int</span> n<span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">if</span><span class="br0">&#40;</span>n==<span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>maxnp=<span class="nu0">3000000</span>;<span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">if</span><span class="br0">&#40;</span>netpay&lt;maxnp<span class="br0">&#41;</span> <span class="br0">&#123;</span>maxnp=netpay;<span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;endl&lt;&lt;<span class="st0">&quot;The maximum net pay for &quot;</span>&lt;&lt;n&lt;&lt;<span class="st0">&quot;employees is&quot;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;setprecision<span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span>&lt;&lt;fixed&lt;&lt;left&lt;&lt;showpoint&lt;&lt;maxnp&lt;&lt;endl;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">return</span> maxnp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//maxnp</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp; <span class="kw4">void</span> payroll:: <span class="me2">sortbypointers</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> </div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  <span class="kw3">cout</span> &lt;&lt; <span class="st0">&quot;Before sorting by pointer:&quot;</span> &lt;&lt; endl;&nbsp; &nbsp; </div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  <span class="kw4">double</span>*p<span class="br0">&#91;</span><span class="nu0">100</span><span class="br0">&#93;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  <span class="kw4">int</span> i,j;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">double</span> *temp;</div></li><li class="li2"><div class="de2">&nbsp; <span class="kw4">int</span> sortedflag=<span class="nu0">0</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i=<span class="nu0">0</span>;i&lt;n;i++<span class="br0">&#41;</span> p<span class="br0">&#91;</span>i<span class="br0">&#93;</span>=netpay+i; <span class="co1">//INITIALIZING POINTER ARRAY</span></div></li><li class="li1"><div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i=<span class="nu0">0</span>;i&lt;n;i++<span class="br0">&#41;</span>cout&lt;&lt; <span class="st0">&quot;$&quot;</span> &lt;&lt; *p<span class="br0">&#91;</span>i<span class="br0">&#93;</span>&lt;&lt;<span class="st0">&quot; &quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span>!sortedflag<span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;  sortedflag=<span class="nu0">1</span>;</div></li><li class="li2"><div class="de2">&nbsp;  <span class="kw1">for</span><span class="br0">&#40;</span>j=<span class="nu0">0</span>;j&lt;n<span class="nu0">-1</span>;j++ <span class="br0">&#41;</span><span class="br0">&#123;</span>&nbsp; </div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>*p<span class="br0">&#91;</span>j<span class="br0">&#93;</span>&gt;*p<span class="br0">&#91;</span>j<span class="nu0">+1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#123;</span> </div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; temp=p<span class="br0">&#91;</span>j<span class="br0">&#93;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  p<span class="br0">&#91;</span>j<span class="br0">&#93;</span>=p<span class="br0">&#91;</span>j<span class="nu0">+1</span><span class="br0">&#93;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  p<span class="br0">&#91;</span>j<span class="nu0">+1</span><span class="br0">&#93;</span>=temp;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp;  sortedflag=<span class="nu0">0</span>;&nbsp; &nbsp; <span class="br0">&#125;</span><span class="co1">//SWAP</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//J</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//I&nbsp;  </span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  cout&lt;&lt;endl&lt;&lt;<span class="st0">&quot;SORTED ARRAY:&quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="kw1">for</span><span class="br0">&#40;</span>i=<span class="nu0">0</span>;i&lt;<span class="nu0">100</span>;i++<span class="br0">&#41;</span>cout&lt;&lt;*p<span class="br0">&#91;</span>i<span class="br0">&#93;</span>&lt;&lt;<span class="st0">&quot; &quot;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="co1">//sortfunction&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2">&nbsp; <span class="kw4">void</span> payroll::<span class="me2">printheaders</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  cout&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">40</span><span class="br0">&#41;</span>&lt;&lt;<span class="st0">&quot;-PAYROLL REPORT-&quot;</span>&lt;&lt;endl;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  cout&lt;&lt;<span class="st0">&quot;-----------------------------------------------------------&quot;</span>&lt;&lt;endl;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  cout&lt;&lt;<span class="st0">&quot; NAME&nbsp;  STAT&nbsp; &nbsp;  HW&nbsp; &nbsp;  HR&nbsp; REGP&nbsp; &nbsp;  OT-PAY&nbsp; GROSS&nbsp;  TAX&nbsp;  NETPAY&quot;</span>&lt;&lt;endl;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  cout&lt;&lt;<span class="st0">&quot;-----------------------------------------------------------&quot;</span>&lt;&lt;endl;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//PRINTHEADINGS</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="kw4">void</span> payroll::<span class="me2">printdata</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;setprecision<span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span>&lt;&lt;setiosflags<span class="br0">&#40;</span>ios::<span class="me2">fixed</span>|ios::<span class="me2">showpoint</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">6</span><span class="br0">&#41;</span>&lt;&lt;employeename&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">6</span><span class="br0">&#41;</span>&lt;&lt;stat&lt;&lt;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setw<span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span>&lt;&lt;hoursworked&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hourlyrate&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;regularpay&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;overtimepay&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;grosspay&lt;&lt;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;taxamount&lt;&lt;setw<span class="br0">&#40;</span><span class="nu0">8</span><span class="br0">&#41;</span>&lt;&lt;netpay&lt;&lt;endl; </div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="co1">//PRINTDATA</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp;  <span class="kw4">void</span> payroll::<span class="me2">printreport</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n=<span class="nu0">0</span>;totalnetpay=<span class="nu0">0</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printheaders<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span>fin&gt;&gt;employeename&gt;&gt;paystat&gt;&gt;hoursworked&gt;&gt;hourlyrate<span class="br0">&#41;</span>;<span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; findgrosspay<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; findtaxamount<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; findnetpay<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printdata<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sortbypointers<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n++; <span class="br0">&#125;</span><span class="co1">//WHILE</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; findavgnetpay<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;<span class="st0">&quot;The average net pay for &quot;</span>&lt;&lt;n&lt;&lt;<span class="st0">&quot; employees is $&quot;</span>&lt;&lt;avgnetpay&lt;&lt;endl;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="co1">//PRINTREPORT</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  payroll employee<span class="br0">&#91;</span><span class="nu0">6</span><span class="br0">&#93;</span>,report;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  employee<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">printreport</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ifstream fin<span class="br0">&#40;</span><span class="st0">&quot;salariedemployees.in&quot;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">while</span><span class="br0">&#40;</span>fin&gt;&gt;aemployeename&gt;&gt;apaystat&gt;&gt;ahoursworked&gt;&gt;ahourlyrate<span class="br0">&#41;</span>;<span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw1">if</span><span class="br0">&#40;</span>apaystat==<span class="st0">'s'</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; employee<span class="br0">&#91;</span>n<span class="br0">&#93;</span>=<span class="kw3">new</span> salaried<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; employee<span class="br0">&#91;</span>n<span class="br0">&#93;</span>-&gt;setvariables<span class="br0">&#40;</span>aemployeename,apaystat,ahoursworked,ahourlyrate<span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; employee<span class="br0">&#91;</span>n<span class="br0">&#93;</span>-&gt;findgrosspay<span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="br0">&#125;</span><span class="co1">//if s</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>apaystat==<span class="st0">'h'</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  employee<span class="br0">&#91;</span>n<span class="br0">&#93;</span>=<span class="kw3">new</span> hourly<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  employee<span class="br0">&#91;</span>n<span class="br0">&#93;</span>-&gt;setvariables<span class="br0">&#40;</span>aemployeename,apaystat,ahoursworked,ahourlyrate<span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  employee<span class="br0">&#91;</span>n<span class="br0">&#93;</span>-&gt;findgrosspay<span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="br0">&#125;</span><span class="co1">//if h&nbsp;  </span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  n++;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//WHILE</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  sortnetpay<span class="br0">&#40;</span>netpay,n<span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  fin.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="kw3">system</span> <span class="br0">&#40;</span><span class="st0">&quot;pause&quot;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="br0">&#125;</span><span class="co1">//MAIN</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li></ol></pre></code> </div>
<br />
[b]I have been working on this for a week, and am really stumped!  I spent 10 hours on it yesterday getting it to where it's at now.  These are my errors:<br />
<br />
 C:\Dev-Cpp\Module 6  again.cpp In member function `void payroll::sortbypointers()': <br />
101 C:\Dev-Cpp\Module 6  again.cpp cannot convert `double' to `double*' in assignment <br />
<br />
 C:\Dev-Cpp\Module 6  again.cpp In member function `void payroll::printdata()': <br />
128 C:\Dev-Cpp\Module 6  again.cpp expected primary-expression before '&lt;&lt;' token <br />
<br />
 C:\Dev-Cpp\Module 6  again.cpp In function `int main()': <br />
151 C:\Dev-Cpp\Module 6  again.cpp `aemployeename' undeclared (first use this function) <br />
151 C:\Dev-Cpp\Module 6  again.cpp `apaystat' undeclared (first use this function) <br />
151 C:\Dev-Cpp\Module 6  again.cpp `ahoursworked' undeclared (first use this function) <br />
151 C:\Dev-Cpp\Module 6  again.cpp `ahourlyrate' undeclared (first use this function) <br />
153 C:\Dev-Cpp\Module 6  again.cpp `n' undeclared (first use this function) <br />
164 C:\Dev-Cpp\Module 6  again.cpp `netpay' undeclared (first use this function) <br />
164 C:\Dev-Cpp\Module 6  again.cpp `sortnetpay' undeclared (first use this function) <br />
<br />
Your help is kindly and greatly appreciated.<br />
/B]</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>SunshineLuvr</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132802.html</guid>
		</item>
		<item>
			<title>CLR Console application vs Win32 Console application</title>
			<link>http://www.daniweb.com/forums/thread132794.html</link>
			<pubDate>Sat, 05 Jul 2008 10:22:47 GMT</pubDate>
			<description>I am using Visual Studio 2005.

Following two programs has the same code, just that one is CLR Console application and the other is Win32 Console application.

I set a break point at int i=1 for both program, for CLR Console application, and when run to the break point, in the local windows,
I have...</description>
			<content:encoded><![CDATA[<div>I am using Visual Studio 2005.<br />
<br />
Following two programs has the same code, just that one is CLR Console application and the other is Win32 Console application.<br />
<br />
I set a break point at int i=1 for both program, for CLR Console application, and when run to the break point, in the local windows,<br />
I have seen none of the value set for the array beans;but for Win32 Console application, the value has been set correctly.<br />
<br />
What is the reason for this different?<br />
====CLR Console application====<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">#include &quot;stdafx.h&quot;<br />
<br />
int main(array&lt;System::String ^&gt; ^args)<br />
{<br />
&nbsp; &nbsp; &nbsp; double beans[3][4];<br />
&nbsp; &nbsp; &nbsp; beans[0][0] = 0;<br />
&nbsp; &nbsp; &nbsp; beans[0][1] = 1;<br />
&nbsp; &nbsp; &nbsp; beans[0][2] = 2;<br />
&nbsp; &nbsp; &nbsp; beans[0][3] = 3;<br />
&nbsp; &nbsp; &nbsp; beans[1][0] = 10;<br />
&nbsp; &nbsp; &nbsp; beans[1][1] = 11;<br />
&nbsp; &nbsp; &nbsp; beans[1][2] = 12;<br />
&nbsp; &nbsp; &nbsp; beans[1][3] = 13;<br />
&nbsp; &nbsp; &nbsp; beans[2][0] = 20;<br />
&nbsp; &nbsp; &nbsp; beans[2][1] = 21;<br />
&nbsp; &nbsp; &nbsp; beans[2][2] = 22;<br />
&nbsp; &nbsp; &nbsp; beans[2][3] = 23;<br />
&nbsp; &nbsp; &nbsp; double (*pbeans) [4] =beans;<br />
&nbsp; &nbsp; &nbsp; pbeans++;<br />
&nbsp; &nbsp; &nbsp; int i=1;<br />
}</code> </div>
====CLR Console application End====<br />
<br />
<br />
===Win32 Console application=====<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">int main(){<br />
&nbsp; &nbsp; &nbsp; double beans[3][4];<br />
&nbsp; &nbsp; &nbsp; beans[0][0] = 0;<br />
&nbsp; &nbsp; &nbsp; beans[0][1] = 1;<br />
&nbsp; &nbsp; &nbsp; beans[0][2] = 2;<br />
&nbsp; &nbsp; &nbsp; beans[0][3] = 3;<br />
&nbsp; &nbsp; &nbsp; beans[1][0] = 10;<br />
&nbsp; &nbsp; &nbsp; beans[1][1] = 11;<br />
&nbsp; &nbsp; &nbsp; beans[1][2] = 12;<br />
&nbsp; &nbsp; &nbsp; beans[1][3] = 13;<br />
&nbsp; &nbsp; &nbsp; beans[2][0] = 20;<br />
&nbsp; &nbsp; &nbsp; beans[2][1] = 21;<br />
&nbsp; &nbsp; &nbsp; beans[2][2] = 22;<br />
&nbsp; &nbsp; &nbsp; beans[2][3] = 23;<br />
&nbsp; &nbsp; &nbsp; double (*pbeans) [4] =beans;<br />
&nbsp; &nbsp; &nbsp; pbeans++;<br />
&nbsp; &nbsp; &nbsp; int i=1;<br />
}</code> </div>
===Win32 Console application End===== <br />
<br />
This is what I see for CLR Console App when debugging<br />
<a rel="nofollow" class="t" href="http://tinyurl.com/5jq4yb" target="_blank">http://tinyurl.com/5jq4yb</a><br />
This is what I see for Win32 Console App when debugging<br />
<a rel="nofollow" class="t" href="http://tinyurl.com/69xzmb" target="_blank">http://tinyurl.com/69xzmb</a><br />
<br />
I am using debug configuration, and <br />
is what appeared in Projects&gt;TestCLR Properties&gt;Configuration Properties&gt;Command Line<br />
/Od /D &quot;WIN32&quot; /D &quot;_DEBUG&quot; /D &quot;_UNICODE&quot; /D &quot;UNICODE&quot; /FD /EHa /MDd /Yu&quot;stdafx.h&quot; /Fp&quot;Debug\TestCLR.pch&quot; /Fo&quot;Debug\\&quot; /Fd&quot;Debug\vc80.pdb&quot; /W3 /nologo /c /Zi /clr /TP /errorReport:prompt /FU &quot;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll&quot; /FU &quot;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll&quot; /FU &quot;c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.XML.dll&quot;<br />
under Active(Debug) configuration.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jack1234</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132794.html</guid>
		</item>
		<item>
			<title>How to run C++ program from a website</title>
			<link>http://www.daniweb.com/forums/thread132781.html</link>
			<pubDate>Sat, 05 Jul 2008 08:04:37 GMT</pubDate>
			<description>I have got a C++ program that accepts a string and gives output as a string now what I need do is take the string input from the textbox on a webpage and then submit the result to a database?

Submitting to database is a later case but first tell me how can I do the first part??</description>
			<content:encoded><![CDATA[<div>I have got a C++ program that accepts a string and gives output as a string now what I need do is take the string input from the textbox on a webpage and then submit the result to a database?<br />
<br />
Submitting to database is a later case but first tell me how can I do the first part??</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>chetan1989</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132781.html</guid>
		</item>
		<item>
			<title>c++ program</title>
			<link>http://www.daniweb.com/forums/thread132766.html</link>
			<pubDate>Sat, 05 Jul 2008 05:27:19 GMT</pubDate>
			<description>Objective 
The objective of this assignment is to provide hands on experience of using 
Classes and Objects 
Dynamic Memory Allocation in C/C++ 
Friend Functions 
Program
Write a C++ program that contains a class named Student having following data members: 

1.	stdId
2.	stdName</description>
			<content:encoded><![CDATA[<div>Objective <br />
The objective of this assignment is to provide hands on experience of using <br />
Classes and Objects <br />
Dynamic Memory Allocation in C/C++ <br />
Friend Functions <br />
Program<br />
Write a C++ program that contains a class named Student having following data members: <br />
<br />
1.	stdId<br />
2.	stdName<br />
3.	stdAge<br />
4.	stdProgram<br />
5.	noOfSubjects.  <br />
<br />
The class Student must have<br />
<br />
•	A default constructor which must initialize all the data members to their meaningful values.<br />
•	A parameterized constructor which takes values for all the data members as parameters and assign them to their respective fields in class.<br />
•	A destructor with no implementation.<br />
•	Setter member functions to set all data members (stdId, stdName, stdAge, stdProgram, and noOfSubjects).<br />
•	Getter member functions to get all data members (stdId, stdName, stdAge, stdProgram and noOfSubjects).<br />
•	Display() member function to display the data for each student. <br />
•	Friend function of class that receives an object of type “Student” <br />
<br />
Display() member function takes no parameters and displays all the student‘s information on the output screen.<br />
<br />
Friend function of class receives an object of type “Student” and determines whether a student has registered in more than five subjects or not. <br />
If a student registers in more than five subjects then it should display a message that “Student has registered in more than 5 subjects” and if a student does not register in more than 5 subjects then it should display a message that “Student has not registered in more than 5 subjects”. <br />
<br />
In main function of the program<br />
	<br />
•	Dynamically allocate memory for two objects of type “Student”. <br />
•	Prompt the user to enter data for each student and store into an object of type “Student”. <br />
•	After setting data for each student, display the data for each student by calling display method. <br />
•	Determines whether a student has registered more than five subjects or not by calling friend function.<br />
•	Deallocate memory that was allocated to objects <br />
<br />
<br />
Sample Output of Program:<br />
<br />
<br />
Please enter data for student 1<br />
<br />
Student ID:                  std01<br />
Student Name:             Sadia <br />
Student Age:                18<br />
Student Program:         BCS <br />
Number of Subjects:    3<br />
<br />
Please enter data for student 2<br />
<br />
Student ID:                  std02 <br />
Student Name:             Sidra<br />
Student Age:                17<br />
Student Program:         BBA<br />
Number of Subjects:    6<br />
<br />
Displaying records for registered students<br />
<br />
Record for Student 1<br />
<br />
Student ID:                  std01<br />
Student Name:             Sadia <br />
Student Age:                18<br />
Student Program:         BCS<br />
Number of Subjects:    3<br />
<br />
<br />
Record for student 2<br />
<br />
Student ID:                  std02 <br />
Student Name:             Sidra<br />
Student Age:                17<br />
Student Program:         BBA<br />
Number of Subjects:    6<br />
	<br />
Student 1 has not registered in more than 5 subjects<br />
Student 2 has registered in more than 5 subjects</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sabib</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132766.html</guid>
		</item>
		<item>
			<title>can i get the full file path from specified file name (.exe)</title>
			<link>http://www.daniweb.com/forums/thread132759.html</link>
			<pubDate>Sat, 05 Jul 2008 03:26:56 GMT</pubDate>
			<description>pleeeeeease
can i get the full file path from specified file name (.exe)
an arbitrary file (.exe)</description>
			<content:encoded><![CDATA[<div>pleeeeeease<br />
can i get the full file path from specified file name (.exe)<br />
an arbitrary file (.exe)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>lahom</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132759.html</guid>
		</item>
		<item>
			<title>Template question</title>
			<link>http://www.daniweb.com/forums/thread132750.html</link>
			<pubDate>Fri, 04 Jul 2008 23:10:20 GMT</pubDate>
			<description><![CDATA[I have a template function as follows:

template <typename T>
int my_func(T& arg)

T is expected to be of type map<T1, T2>.  T1 is expected to be of a basic type (int, long, etc.) and T2 is expected to be of type vector<T1>/list<T1>/etc.

I want to iterate over the contents of T2.  How can I do...]]></description>
			<content:encoded><![CDATA[<div>I have a template function as follows:<br />
<br />
template &lt;typename T&gt;<br />
int my_func(T&amp; arg)<br />
<br />
T is expected to be of type map&lt;T1, T2&gt;.  T1 is expected to be of a basic type (int, long, etc.) and T2 is expected to be of type vector&lt;T1&gt;/list&lt;T1&gt;/etc.<br />
<br />
I want to iterate over the contents of T2.  How can I do this when I do not know what type T2 is?  For example:<br />
<br />
T2::const_iterator pos = ...;</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>titaniumdecoy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132750.html</guid>
		</item>
		<item>
			<title>C++ Style</title>
			<link>http://www.daniweb.com/forums/thread132747.html</link>
			<pubDate>Fri, 04 Jul 2008 22:28:12 GMT</pubDate>
			<description>What do you think of this?

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml</description>
			<content:encoded><![CDATA[<div>What do you think of this?<br />
<br />
<a rel="nofollow" class="t" href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml" target="_blank">http://google-styleguide.googlecode....k/cppguide.xml</a></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>sarehu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132747.html</guid>
		</item>
		<item>
			<title>Is this legal?</title>
			<link>http://www.daniweb.com/forums/thread132741.html</link>
			<pubDate>Fri, 04 Jul 2008 21:12:09 GMT</pubDate>
			<description><![CDATA[If I declare a struct node, is the following legal in C++?

node nodes_array[vector.size()];

I know this is not legal in C.  However, my C++ compiler does not complain.  Is this only in recent versions of C++, or has this always been legal in C++?]]></description>
			<content:encoded><![CDATA[<div>If I declare a struct node, is the following legal in C++?<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">node nodes_array[vector.size()];</code> </div>
<br />
<br />
I know this is not legal in C.  However, my C++ compiler does not complain.  Is this only in recent versions of C++, or has this always been legal in C++?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>titaniumdecoy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132741.html</guid>
		</item>
		<item>
			<title>vc++ help</title>
			<link>http://www.daniweb.com/forums/thread132731.html</link>
			<pubDate>Fri, 04 Jul 2008 18:47:43 GMT</pubDate>
			<description>I am doing a project in vc++,mfc.what i have to do is,identify static objects in a scene and track them for changes(in position).for that i have to get the pixels of the objects.is there any method to detect all objects and identify their pixels.i have to use the frames obtained from an ip...</description>
			<content:encoded><![CDATA[<div>I am doing a project in vc++,mfc.what i have to do is,identify static objects in a scene and track them for changes(in position).for that i have to get the pixels of the objects.is there any method to detect all objects and identify their pixels.i have to use the frames obtained from an ip camera.these frames have then to be compared in the further execution .differences in position for this static objects should generate an alarm.any help???</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>camproject</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132731.html</guid>
		</item>
		<item>
			<title><![CDATA[cin.sync & cin.clear & infinte loop]]></title>
			<link>http://www.daniweb.com/forums/thread132714.html</link>
			<pubDate>Fri, 04 Jul 2008 16:18:59 GMT</pubDate>
			<description><![CDATA[hello all

i dont know what is the problem ....... a very simple change in the order of functions make the program goes in infinite loop

this code works will
#include <iostream>
using namespace std;
int main()
{
    int i;]]></description>
			<content:encoded><![CDATA[<div>hello all<br />
<br />
i dont know what is the problem ....... a very simple change in the order of functions make the program goes in infinite loop<br />
<br />
this code works will<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1"><span class="co2">#include &lt;iostream&gt;</span></div></li><li class="li1"><div class="de1"><span class="kw2">using</span> <span class="kw2">namespace</span> std;</div></li><li class="li1"><div class="de1"><span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw4">int</span> i;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cout</span> &lt;&lt; <span class="st0">&quot;<span class="es0">\n</span>Enter Intger:&quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span> &gt;&gt; i;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">cin</span>.<span class="me1">good</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">break</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span>.<span class="me1">sync</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span>.<span class="me1">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span>.<span class="me1">sync</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cout</span> &lt;&lt; <span class="st0">&quot;<span class="es0">\n</span>Error<span class="es0">\n</span>&quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw3">cout</span> &lt;&lt; <span class="st0">&quot;<span class="es0">\n</span>You Entered :&quot;</span>&lt;&lt;i;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw1">return</span> <span class="nu0">0</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></code> </div>
<br />
but when i swap cin.sync and cin.clear<br />
like that<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1"><span class="co2">#include &lt;iostream&gt;</span></div></li><li class="li1"><div class="de1"><span class="kw2">using</span> <span class="kw2">namespace</span> std;</div></li><li class="li1"><div class="de1"><span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw4">int</span> i;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cout</span> &lt;&lt; <span class="st0">&quot;<span class="es0">\n</span>Enter Intger:&quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span> &gt;&gt; i;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">cin</span>.<span class="me1">good</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">break</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span>.<span class="me1">sync</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span>.<span class="me1">sync</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cin</span>.<span class="me1">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cout</span> &lt;&lt; <span class="st0">&quot;<span class="es0">\n</span>Error<span class="es0">\n</span>&quot;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw3">cout</span> &lt;&lt; <span class="st0">&quot;<span class="es0">\n</span>You Entered :&quot;</span>&lt;&lt;i;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw1">return</span> <span class="nu0">0</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></code> </div>
infinite loop happens<br />
<br />
why ?? and please if any one has a link that takes about buffer please give it to me</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>TeCNoYoTTa</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132714.html</guid>
		</item>
		<item>
			<title>Debug assertion failed</title>
			<link>http://www.daniweb.com/forums/thread132704.html</link>
			<pubDate>Fri, 04 Jul 2008 14:21:39 GMT</pubDate>
			<description>Hi all,

I got this assertion problem that i cant seem to solve, could you guys help me on this. So far, i think the problem might be due to the while loop for the iterator line by line check and i have made changes to it but still cant solve it.

Debug assertion...</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I got this assertion problem that i cant seem to solve, could you guys help me on this. So far, i think the problem might be due to the while loop for the iterator line by line check and i have made changes to it but still cant solve it.<br />
<br />
Debug assertion failed<br />
<br />
file:f\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c<br />
Line: 1317<br />
Expression: _CrtIsValidHeappointer(pUserData)<br />
<br />
file:f\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c<br />
Line: 1419<br />
Expression: _pFirstBlock == pHead<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">private: System::Void button1_Click(System::Object^&nbsp; sender, System::EventArgs^&nbsp; e)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream ckin(&quot;sample.txt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int initclock = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (ckin==NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox::Show (&quot;not found&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ckin.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; initclock++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (ckin!=NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char checkEmpty;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ckin.get(checkEmpty);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!ckin.eof()) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {textBox1-&gt;Text = &quot;file empty&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ckin.close();<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; {textBox1-&gt;Text = &quot;not empty&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ckin.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; initclock++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream in(&quot;sample.txt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; string line;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string match(&quot;sample\:&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int clock = 0 ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (getline(in, line)&amp;&amp;(initclock==0))<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; stringstream sstrm(line);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string::iterator iter =<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search (line.begin(),line.end(),match.begin(),match.end());<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; &nbsp; &nbsp; &nbsp; &nbsp; if (iter != line.end() )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  iter = find_if( iter +match.length(), line.end(),not1(ptr_fun &lt;int,int&gt; (isspace)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (iter == line.end())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox::Show (&quot;No numbers or words after Serial no. :&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string::iterator j = find_if (iter, line.end(), ptr_fun &lt;int,int&gt; (isspace));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string found;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; copy(iter, j, back_insert_iterator &lt;string&gt; (found));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //create a new file based on the word after said word<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //and saved it into the said folder<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string filename = found + &quot;.txt&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string dirname = &quot;log//&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string finaldir = dirname + filename;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ofstream(finaldir.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //using ifstream and ofstream to copy content of file to another<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char * fbuffer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; long fsize;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifstream cpy (&quot;sample.txt&quot;,ios::binary);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ofstream target (finaldir.c_str(),ios::binary);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cpy.seekg(0,ifstream::end);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fsize=cpy.tellg();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cpy.seekg(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fbuffer = new char [fsize];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cpy.read (fbuffer,fsize);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target.write (fbuffer,fsize);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delete[] fbuffer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cpy.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target.close();<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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //write the found word/serial no. into temp.txt<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const char * buffer=found.c_str();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string str (found.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int sizeNum = str.length();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; long size = sizeNum;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ofstream outfile (&quot;store.txt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outfile.write (buffer,size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //delete[] buffer;//release dynamically allocated memory<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outfile.close ();<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; //textbox update and check if previous saved name is the same as <br />
&nbsp; &nbsp; &nbsp; &nbsp; //current one<br />
&nbsp; &nbsp; &nbsp; &nbsp; textBox2-&gt;Text = System::IO::File::ReadAllText(&quot;store.txt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (textBox2-&gt;Text == label3-&gt;Text)&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; MessageBox::Show (&quot;no. repeated&quot;);<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; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label3-&gt;Text = textBox2-&gt;Text;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; //try to use an empty file to write and empty a file <br />
&nbsp; &nbsp; &nbsp; &nbsp; //which is being used by another program<br />
&nbsp; &nbsp; &nbsp; &nbsp; char * ebuffer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; long esize;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream ecpy (&quot;void.txt&quot;,ios::binary);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ofstream etarget (&quot;sample.txt&quot;,ios::binary);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ecpy.seekg(0,ifstream::end);<br />
&nbsp; &nbsp; &nbsp; &nbsp; esize=ecpy.tellg();<br />
&nbsp; &nbsp; &nbsp; &nbsp; ecpy.seekg(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ebuffer = new char [esize];<br />
&nbsp; &nbsp; &nbsp; &nbsp; ecpy.read (ebuffer,esize);<br />
&nbsp; &nbsp; &nbsp; &nbsp; etarget.write (ebuffer,esize);<br />
&nbsp; &nbsp; &nbsp; &nbsp; delete[] ebuffer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ecpy.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; etarget.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; textBox1-&gt;Text = &quot;done&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; clock++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; in.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (clock!=0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; break;<br />
}//if iter<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; textBox1-&gt;Text = &quot;not found&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}//while<br />
}</code> </div></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>integer*09</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread132704.html</guid>
		</item>
	</channel>
</rss>
