<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwizguide.com/rss_namespace/">
 <channel>
  <title>C and C++ Programming Forum</title>
  <link>http://www.mycplus.com/forum/</link>
  <description>This is an XML content feed of; C and C++ Programming Forum : Last 10 Posts</description>
  <pubDate>Fri, 09 May 2008 17:42:33 +0000</pubDate>
  <lastBuildDate>Fri, 09 May 2008 13:16:37 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 0.00</generator>
  <ttl>30</ttl>
  <WebWizForums:feedURL>www.mycplus.com/forum/RSS_topic_feed.asp</WebWizForums:feedURL>
  <image>
   <title>C and C++ Programming Forum</title>
   <url>http://www.mycplus.com/forum/forum_images/web_wiz_forums.png</url>
   <link>http://www.mycplus.com/forum/</link>
  </image>
  <item>
   <title>Basics of C# : pls help C# program 2 calc power consumtion</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=483&amp;PID=856#856</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1061" rel="nofollow">cos130</a><br /><strong>Subject:</strong> pls help C# program 2 calc power consumtion<br /><strong>Posted:</strong> 09&#194;&#160;-&#194;&#160;May&#194;&#160;-&#194;&#160;2008 at 13:16<br /><br /><DIV>can someone help I need to write a program which can calculate monthly power consumption when given a list of devices together with their power consumption and usage duration in a month and will read from the file and display this information in a user interface in C#.</DIV><DIV>&nbsp;</DIV><DIV>thanks</DIV>]]>
   </description>
   <pubDate>Fri, 09 May 2008 13:16:37 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=483&amp;PID=856#856</guid>
  </item> 
  <item>
   <title>C++ : C#:a program to calculate monthly power consumptio</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=482&amp;PID=855#855</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1061" rel="nofollow">cos130</a><br /><strong>Subject:</strong> C#:a program to calculate monthly power consumptio<br /><strong>Posted:</strong> 09&#194;&#160;-&#194;&#160;May&#194;&#160;-&#194;&#160;2008 at 13:09<br /><br /><img src="http://www.mycplus.com/forum/forum_images/post_butt&#111;n_font.gif" border="0" /><DIV>hi there</DIV><DIV>can someone help I need to write a program which can calculate monthly power consumption when given a list of devices together with their power consumption and usage duration in a month and will read from the file and display this information in a user interface in C#.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>need help urgent.</DIV><DIV>thanks</DIV>]]>
   </description>
   <pubDate>Fri, 09 May 2008 13:09:18 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=482&amp;PID=855#855</guid>
  </item> 
  <item>
   <title>C Language : Plz help me with this problem</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=481&amp;PID=854#854</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1059" rel="nofollow">zuberi5</a><br /><strong>Subject:</strong> Plz help me with this problem<br /><strong>Posted:</strong> 08&#194;&#160;-&#194;&#160;May&#194;&#160;-&#194;&#160;2008 at 08:29<br /><br />I have to made a Turbo C file which will do this:<BR>firstly, i press print screen button from my keyboard then i will double click the exe&nbsp;of the&nbsp;file i have to make. the exe file will get the captured image from memory and then it will saves it on the hard drive's specific location.<DIV>plz help me on how to do it</DIV><DIV>any logic?????<BR></DIV>]]>
   </description>
   <pubDate>Thu, 08 May 2008 08:29:14 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=481&amp;PID=854#854</guid>
  </item> 
  <item>
   <title>C++ : Types Of recursion</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=480&amp;PID=853#853</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=873" rel="nofollow">asadullah.ansari</a><br /><strong>Subject:</strong> Types Of recursion<br /><strong>Posted:</strong> 07&#194;&#160;-&#194;&#160;May&#194;&#160;-&#194;&#160;2008 at 02:07<br /><br /><div style="text-align: left; font-family: arial,helvetica,sans-serif;"><font size="3">Detail About Recursion and its Type<br><br>Here I am going to give a detail about Recursion in C++. <br>Definition:&nbsp; Recursion is the process where a function is calleditself but stack frame will be out of limit because function call willbe infinite times. So a termination condition is mandatory to arecursion. <br>In C++, Recursion can be divided into two types:<br>(a)&nbsp;&nbsp; &nbsp;Run- Time Recursion:&nbsp; Normal as in C<br>(b)&nbsp;&nbsp; &nbsp;Compile- Time Recursion: By using Template<br><br>Each of these can be also divided into following types:<br><br>1.&nbsp;&nbsp; &nbsp;Linear Recursion<br>2.&nbsp;&nbsp; &nbsp;Binary Recursion<br>3.&nbsp;&nbsp; &nbsp;Tail Recursion<br>4.&nbsp;&nbsp; &nbsp;Mutual Recursion<br>5.&nbsp;&nbsp; &nbsp;Nested Recursion<br><br><br>1.&nbsp; Linear Recursion:&nbsp; This recursion is the most commonlyused. In this recursion a function call itself in a simple manner andby termination condition it terminates. This process called 'Winding'and when it returns to caller that is called 'Un-Winding'. Terminationcondition also known as Base condition.<br><br>Example: Factorial calculation by linear recursion<br><br>Run-Time Version <br><br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp;int Fact(long n)<br>{<br>&nbsp;&nbsp;&nbsp; &nbsp;if(0&gt;n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp; &nbsp;if(0 == n)<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp; &nbsp;else<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ( n* Fact(n-1));<br>}<br>}<br></pre></td></tr></table><br><br><br><br><br><br>Winding Process:<br><br>Functioncalled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Function return<br><br>Fact(6)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6*Fact(5)<br>Fact(5)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5*Fact(4)<br>Fact(4)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; 4*Fact(3)<br>Fact(3)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;3* Fact(2)<br>Fact(2)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;2* Fact(1)<br>Fact(1)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;1* Fact(0)<br>Terminating Point<br>Fact(0)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;1<br><br>Unwinding Process<br><br>Fact(1)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;1*1<br>Fact(2)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;2*1<br>Fact(3)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;3*2*1<br>Fact(4)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;4*3*2*1<br>Fact(5)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;5*4*3*2*1<br>Fact(6)&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;6*5*4*3*2*1<br><br><br>Compile-Time Version<br><br><table width="99%"><tr><td><pre class="BBcode"><br>// template for Base Condition<br>template &lt;&gt;<br>struct Fact&lt;0&gt;<br>{<br>&nbsp;&nbsp; enum <br>&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; factVal = 1 <br>&nbsp;&nbsp; };<br>};<br><br>template &lt;int n&gt;<br>struct Fact<br>{<br>&nbsp;&nbsp; // Recursion call by linear method<br>&nbsp;&nbsp; enum<br>&nbsp; { <br>value = n * Fact&lt;n - 1&gt;::factVal<br>&nbsp;&nbsp; };<br>};</pre></td></tr></table><br>To test it how it's working at compile time, just call <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; Fact&lt;-1&gt;::factVal ;<br>And compile it then compiler error will come, because no template for -1.<br><br>2.&nbsp; Binary Recursion: Binary Recursion is a process where functionis called twice at a time inplace of once at a time. Mostly it's usingin data structure like operations for tree as traversal, findingheight, merging, etc. <br><br>Example: Fibonacci number<br><br>Run Time Version Code:<br><table width="99%"><tr><td><pre class="BBcode"><br>int FibNum(int n)<br>{<br>&nbsp;&nbsp; // Base conditions<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (n &lt; 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (1 == n || 2 == n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<br><br>&nbsp;&nbsp; // Recursive call by Binary Method<br>&nbsp;&nbsp;&nbsp;&nbsp; return FibNum(n - 1) + FibNum(n -2);&nbsp;&nbsp; // At a time two recursive function calledso&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp; binary<br>}</pre></td></tr></table><br><br>Compile Time Version Code<br><table width="99%"><tr><td><pre class="BBcode"><br>// Base Conditions<br>template&lt;&gt;<br>struct FibNum&lt;2&gt;<br>{<br>&nbsp;&nbsp; enum { val = 1 };<br>};<br>template &lt;&gt;<br>struct FibNum&lt;1&gt;<br>{<br>&nbsp;&nbsp; enum { val = 1 };<br>};<br><br>// Recursive call by Binary Method<br>template &lt;int n&gt;<br>struct FibNum<br>{&nbsp; &nbsp;<br>&nbsp;&nbsp; enum { val= FibNum&lt;n - 1&gt;::val + FibNum&lt;n - 2&gt;::val };<br>};</pre></td></tr></table><br>3.&nbsp; Tail&nbsp; Recursion: In this method, recursive function iscalled at the last. So it's more efficient than linear recursionmethod. Means you can say termination point will come(100%) only youhave to put that condition.<br><br>Example: Fibonacci number<br><br>Run Time Version Code:<br><table width="99%"><tr><td><pre class="BBcode"><br>int FibNum(int n, int x, int y)<br>{&nbsp; &nbsp;<br>&nbsp;&nbsp; if (1 == n)&nbsp;&nbsp;&nbsp; // Base Condition<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return y;<br>&nbsp;&nbsp; }<br>&nbsp;&nbsp; else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Recursive call by Tail method<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return FibNum(n-1, y, x+y);<br>&nbsp;&nbsp; }<br>}<br></pre></td></tr></table><br>Compile Time Version Code<br><br><table width="99%"><tr><td><pre class="BBcode"><br>template &lt;int n, int x, int y&gt;<br>struct FibNum<br>{<br>&nbsp;&nbsp; // Recursive call By tail method<br>&nbsp;&nbsp; enum <br>&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = FibNum&lt;n-1, y, (x+y)&gt;::val<br>&nbsp;&nbsp; };<br>};<br><br>// Base Condition or Termination <br>template&lt;int x, int y&gt;<br>struct FibNum&lt;1, x, y&gt;<br>{<br>&nbsp;&nbsp; enum <br>&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = y <br>&nbsp;&nbsp; };<br>};</pre></td></tr></table><br><br><br><br><br>4.&nbsp; Mutual&nbsp; Recursion:&nbsp; Functions calling each other.Let's say FunA calling FunB and FunB calling FunA recursively. This isnot actually not recursive but it's doing same as recursive. So you cansay Programming languages which are not supporting recursive calls,mutual recursion can be applied there to fulfill the requirement ofrecursion. Base condition can be applied to any into one or more thanone or all functions.<br><br>Example: To find Even Or Odd number<br><br>Run Time Version Code:<br><table width="99%"><tr><td><pre class="BBcode"><br>bool IsOddNumber(int n)<br>{<br>&nbsp;&nbsp; // Base or Termination Condition<br>&nbsp;&nbsp; if (0 == n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Recursive call by Mutual Method<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return IsEvenNumber(n - 1);<br>}<br><br>bool IsEvenNumber(int n)<br>{<br>&nbsp;&nbsp; // Base or Termination Condition<br>&nbsp;&nbsp; if (0 == n)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<br>&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Recursive call by Mutual Method<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return IsOddNumber(n - 1);<br>}<br></pre></td></tr></table><br><br>Compile Time Version Code<br><br><table width="99%"><tr><td><pre class="BBcode"><br><br>// Base Or Termination Conditions<br>template &lt;&gt;<br>struct IsOddNumber&lt;0&gt;<br>{<br>&nbsp;&nbsp; enum <br>&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp; val = 0 <br>&nbsp; };<br>};<br>template &lt;&gt;<br>struct IsEvenNumber&lt;0&gt;<br>{<br>&nbsp;&nbsp; enum <br>&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = 1 <br>&nbsp; };<br>};<br><br>// Recursive calls by Mutual Method<br><br>template &lt;int n&gt;<br>struct IsOddNumber<br>{<br>&nbsp;&nbsp; enum <br>&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = n == 0 ? 0 : IsEvenNumber&lt;n - 1&gt;::val <br>&nbsp;&nbsp; };<br>};<br><br><br>template &lt;int n&gt;<br>struct IsEvenNumber<br>{<br>&nbsp;&nbsp; enum <br>&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = n == 0 ? 1 : IsOddNumber&lt;n - 1&gt;::val<br>&nbsp; };<br>};<br><br>&nbsp;</pre></td></tr></table><br><br>3.&nbsp; Nested&nbsp; Recursion:&nbsp; It's very different than allrecursions. All recursion can be converted to iterative (loop) exceptnested recursion. You can understand this recursion by example ofAckermann function.<br><br>Example: Ackermann function<br><br>Run Time Version Code:<br><table width="99%"><tr><td><pre class="BBcode"><br>int Ackermann(int x, int y)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Base or Termination Condition<br>&nbsp;&nbsp;&nbsp; if (0 == x)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return y + 1;<br>&nbsp;}&nbsp; &nbsp;<br>// Error Handling condition<br>&nbsp;&nbsp; if (x &lt; 0&nbsp; ||&nbsp; y &lt; 0)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp; } &nbsp;<br>// Recursive call by Linear method <br>&nbsp;&nbsp; else if (x &gt; 0 &amp;&amp; 0 == y) <br>&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Ackermann(x-1, 1);<br>&nbsp; }<br>&nbsp;&nbsp; // Recursive call by Nested method<br>&nbsp;&nbsp; else<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Ackermann(x-1, Ackermann(x, y-1));<br>&nbsp; }<br>}</pre></td></tr></table><br><br>Compile Time Version Code<br><table width="99%"><tr><td><pre class="BBcode"><br>// Base Or Termination condition<br>template &lt;int y&gt;<br>struct Ackermann&lt;0, y&gt;<br>{<br>&nbsp;&nbsp; enum { val = y + 1 };<br>};<br><br>&nbsp;&nbsp; // Recursive Call by Linear Method<br>template &lt;int x&gt;<br>struct Ackermann&lt;x, 0&gt;<br>{<br>&nbsp;&nbsp; enum <br>&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = Ackermann&lt;x-1, 1&gt;::val<br>&nbsp;&nbsp; };<br>};<br><br>// Recursive Call by Nested Method<br>template &lt;int x, int y&gt;<br>struct Ackermann<br>{<br>&nbsp;&nbsp; Enum<br>&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; val = Ackermann&lt;x-1, Ackermann&lt;x, y-1&gt; ::val&gt;::val <br>};<br>};</pre></td></tr></table><br><br><br></font></div>]]>
   </description>
   <pubDate>Wed, 07 May 2008 02:07:52 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=480&amp;PID=853#853</guid>
  </item> 
  <item>
   <title>C++ : How this code works?</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=473&amp;PID=852#852</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1034" rel="nofollow">emg</a><br /><strong>Subject:</strong> How this code works?<br /><strong>Posted:</strong> 06&#194;&#160;-&#194;&#160;May&#194;&#160;-&#194;&#160;2008 at 22:52<br /><br />why no one hs answered me .<img src="http://www.mycplus.com/forum/smileys/smiley19.gif" height="17" width="17" border="0" alt="Cry" />]]>
   </description>
   <pubDate>Tue, 06 May 2008 22:52:49 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=473&amp;PID=852#852</guid>
  </item> 
  <item>
   <title>Graphics in C/C++ : Import an excel chart to a c++ array</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=479&amp;PID=851#851</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1056" rel="nofollow">pa</a><br /><strong>Subject:</strong> Import an excel chart to a c++ array<br /><strong>Posted:</strong> 05&#194;&#160;-&#194;&#160;May&#194;&#160;-&#194;&#160;2008 at 07:49<br /><br />Hello!<DIV>I have a lot of data that have to be implemented with Visual C++ 2005 express. I'd simply like to import them in an array in order not to have to copy them by hand on this scheme : {0,0,1,5,0,5}<FONT size=2>.</FONT></DIV><DIV><FONT size=2>I did something similar with pictures using templates (function LoadImage).</FONT></DIV><DIV><FONT size=2>Maybe there is a library that has functions enabling this process.</FONT></DIV><DIV><FONT size=2>Thank you for helping me.</FONT></DIV>]]>
   </description>
   <pubDate>Mon, 05 May 2008 07:49:15 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=479&amp;PID=851#851</guid>
  </item> 
  <item>
   <title>C Language : threads Win32 &lt;-&gt; Linux</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=478&amp;PID=850#850</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1050" rel="nofollow">JackSparrow</a><br /><strong>Subject:</strong> threads Win32 &lt;-&gt; Linux<br /><strong>Posted:</strong> 29&#194;&#160;-&#194;&#160;April&#194;&#160;-&#194;&#160;2008 at 13:15<br /><br />Ok, I found the problem/solution but I'm not satisfied:<br>All works fine when the optimizations in gcc are turned off.<br>Each optimization (O, O1, O2, O3, Os) will cause an endless loop.<br><br>Here an example:<br><br><sub><span style="font-family: Courier New,Courier,mono;">#include &lt;stdio.h&gt;<br>#include &lt;pthread.h&gt;<br><br>int wait1,wait2;<br><br>void *mythread(void *ptr)<br>{<br>&nbsp; int *parm;<br>&nbsp; int i;<br><br>&nbsp; parm=(int *)ptr;<br><br>&nbsp; for (i=0;i&lt;10;i++)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; // branch for thread no 1<br>&nbsp;&nbsp;&nbsp; if (parm&#091;0&#093;)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("\nLoop %i\n",i);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Thread 1 started and waiting for thread 2 ...\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wait2=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (wait1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wait1=1;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Thread 1 resumed.\n");<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; // branch for thread no 2<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (wait2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wait2=1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Thread 2 started and telling Thread 1 to resume ...\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wait1=0;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br><br>&nbsp; return NULL;<br>}<br><br>int main()<br>{<br>&nbsp; pthread_t thr1,thr2;<br>&nbsp; int parm1&#091;1&#093;,parm2&#091;1&#093;;<br><br>&nbsp; wait1=1;<br>&nbsp; wait2=1;<br>&nbsp; parm1&#091;0&#093;=1;<br>&nbsp; parm2&#091;0&#093;=0;<br><br>&nbsp; pthread_create(&amp;thr1,NULL,mythread,(void *)parm1);<br>&nbsp; pthread_create(&amp;thr2,NULL,mythread,(void *)parm2);<br><br>&nbsp; pthread_join(thr1,NULL);<br>&nbsp; pthread_join(thr2,NULL);<br><br>&nbsp; return 0;<br>}<br><br><br></span></sub>]]>
   </description>
   <pubDate>Tue, 29 Apr 2008 13:15:25 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=478&amp;PID=850#850</guid>
  </item> 
  <item>
   <title>C Language : base conversion</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=348&amp;PID=849#849</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1050" rel="nofollow">JackSparrow</a><br /><strong>Subject:</strong> base conversion<br /><strong>Posted:</strong> 28&#194;&#160;-&#194;&#160;April&#194;&#160;-&#194;&#160;2008 at 15:23<br /><br />This code could do this from base 2-10 to base 2-10.<br />There is a nice function called itoa that converts<br />int to char* and you can specify the base.<br />Unfortunatelly the function atoi has no base-parameter.<br />So I recoded it:<br /><br />#include &lt;stdio.h&gt;<br />#include &lt;stdlib.h&gt;<br /><br />int xy(int x,int y)<br />{<br />  int r=1,i;<br /><br />  for (i=0;i&lt;y;i++)<br />  {<br />&nbsp;&nbsp;&nbsp;&nbsp;r*=x;<br />  }<br /><br />  return r;<br />}<br /><br />int my_atoi(char *s,int base)<br />{<br />  int r=0,i,j,pos=0;<br /><br />  for (j=0;j&lt;80 && s&#091;j&#093;!=0 && s&#091;j&#093;&gt;='0' && s&#091;j&#093;&lt;='9';j++);<br /><br />  for (i=j-1;i&gt;=0;i--)<br />  {<br />&nbsp;&nbsp;&nbsp;&nbsp;r+=(s<em>-'0')*xy(base,pos);<br />&nbsp;&nbsp;&nbsp;&nbsp;pos++;<br />  }<br /><br />  return r;<br />}<br /><br />int main()<br />{<br />  char buff&#091;83&#093;;<br />  int num,b1,b2;<br /><br />  printf("from base:");<br />  fgets(buff,80,stdin);<br />  b1=atoi(buff);<br /><br />  printf("  to base:");<br />  fgets(buff,80,stdin);<br />  b2=atoi(buff);<br /><br />  printf("Number:");<br />  fgets(buff,80,stdin);<br />  num=my_atoi(buff,b1);<br /><br />  itoa(num,buff,b2);<br /><br />  printf("\nresult is %s\n",buff);<br /><br />  return 0;<br />}<br />]]>
   </description>
   <pubDate>Mon, 28 Apr 2008 15:23:38 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=348&amp;PID=849#849</guid>
  </item> 
  <item>
   <title>C Language : Regarding replacing line of code??</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=476&amp;PID=848#848</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1050" rel="nofollow">JackSparrow</a><br /><strong>Subject:</strong> Regarding replacing line of code??<br /><strong>Posted:</strong> 28&#194;&#160;-&#194;&#160;April&#194;&#160;-&#194;&#160;2008 at 12:14<br /><br />Sorry, your code looks very strange to me.<br>Where do you want to place the output-file ?<br>You opened an input-file for read-only. There you can't make any changes.<br><br>Perhaps this should help you:<br><br><span style="font-family: Courier New,Courier,mono;">#include &lt;stdio.h&gt;<br><br>int main(int argc,char **argv)<br>{<br>&nbsp; const int max=1024;<br>&nbsp; int r=0,i;<br>&nbsp; FILE *in,*out;<br>&nbsp; char buff&#091;max+3&#093;;<br><br>&nbsp; if (argc!=3)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; r=1;<br>&nbsp;&nbsp;&nbsp; printf("usage: lower &lt;src&gt; &lt;dest&gt;\n");<br>&nbsp; }<br>&nbsp; else<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; if ((in=fopen(argv&#091;1&#093;,"rb"))==NULL)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r=2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("cannot open input-file!\n");<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Output file will be overwritten when exists !!!<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((out=fopen(argv&#091;2&#093;,"wb"))==NULL)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r=3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("cannot open output-file!\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (!feof(in))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buff&#091;0&#093;=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fgets(buff,max,in);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i=0;i&lt;max &amp;&amp; buff<em>!=0 &amp;&amp; buff<em>!='\r' &amp;&amp; buff<em>!='\n' &amp;&amp; (buff<em>==' ' || buff<em>=='\t');i++);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (buff<em>=='#')<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i=i+1;i&lt;max &amp;&amp; buff<em>!=0 &amp;&amp; buff<em>!='\r' &amp;&amp; buff<em>!='\n';i++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buff<em>=tolower(buff<em>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fputs(buff,out);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fclose(out);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fclose(in);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br><br>&nbsp; return r;<br>}<br><br></span>]]>
   </description>
   <pubDate>Mon, 28 Apr 2008 12:14:36 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=476&amp;PID=848#848</guid>
  </item> 
  <item>
   <title>C Language : Copy/Read/Write a binary file(.mp3)</title>
   <link>http://www.mycplus.com/forum/forum_posts.asp?TID=475&amp;PID=847#847</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.mycplus.com/forum/member_profile.asp?PF=1050" rel="nofollow">JackSparrow</a><br /><strong>Subject:</strong> Copy/Read/Write a binary file(.mp3)<br /><strong>Posted:</strong> 28&#194;&#160;-&#194;&#160;April&#194;&#160;-&#194;&#160;2008 at 11:42<br /><br /><span style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">Well, that's C++-code.<br><br>In C this would look like that:<br><br>#include &lt;stdio.h&gt;<br><br>int main(int argc,char **argv)<br>{<br>&nbsp; int r=0,sz;<br>&nbsp; FILE *f1,*f2;<br>&nbsp; char buff&#091;4096&#093;;<br><br>&nbsp; if (argc!=3)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; r=1;<br>&nbsp;&nbsp;&nbsp; printf("usage: cop &lt;source&gt; &lt;dest&gt;\n");<br>&nbsp; }<br>&nbsp; else<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; if ((f1=fopen(argv&#091;1&#093;,"rb"))==NULL)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r=2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("cannot open input-file!\n");<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((f2=fopen(argv&#091;2&#093;,"wb"))==NULL)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r=3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("cannot open output-file!\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (!feof(f1))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sz=fread(buff,1,4096,f1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fwrite(buff,sz,1,f2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fclose(f2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fclose(f1);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br><br>&nbsp; return r;<br>}<br><br></span></span>]]>
   </description>
   <pubDate>Mon, 28 Apr 2008 11:42:51 +0000</pubDate>
   <guid isPermaLink="true">http://www.mycplus.com/forum/forum_posts.asp?TID=475&amp;PID=847#847</guid>
  </item> 
 </channel>
</rss>