<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>This site has been moved to http://techievibes.com</title>
	<atom:link href="http://cppkid.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cppkid.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sun, 22 Jan 2012 11:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cppkid.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>This site has been moved to http://techievibes.com</title>
		<link>http://cppkid.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cppkid.wordpress.com/osd.xml" title="This site has been moved to http://techievibes.com" />
	<atom:link rel='hub' href='http://cppkid.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Moving to a new home</title>
		<link>http://cppkid.wordpress.com/2010/02/13/moving-to-a-new-home/</link>
		<comments>http://cppkid.wordpress.com/2010/02/13/moving-to-a-new-home/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 10:49:52 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=309</guid>
		<description><![CDATA[After a while, I&#8217;m back and this time with a new home. The blog is migrated to a new home under a new name. http://techievibes.com My idea had always been sharing what I learnt and I hope you enjoyed cppkid and with techievibes, I promise more enjoyment. Once again, thanks for all the support you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=309&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="attachment_310" class="wp-caption aligncenter" style="width: 210px"><a href="http://cppkid.files.wordpress.com/2010/02/new-home.jpg"><img class="size-medium wp-image-310" title="Home Ownership Keys" src="http://cppkid.files.wordpress.com/2010/02/new-home.jpg?w=200&#038;h=300" alt="" width="200" height="300" /></a><p class="wp-caption-text">image courtesy : http://www.anson-real-estate.com</p></div>
<p>After a while, I&#8217;m back and this time with a new home. The blog is migrated to a new home under a new name.</p>
<p><a class="aligncenter" title="techievibes - sharing technology" href="http://techievibes.com" target="_self">http://techievibes.com</a></p>
<p>My idea had always been sharing what I learnt and I hope you enjoyed cppkid and with techievibes, I promise more enjoyment.</p>
<p>Once again, thanks for all the support you have provided.</p>
<p>Cppkid</p>
<br />Filed under: <a href='http://cppkid.wordpress.com/category/c/'>C++</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/309/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/309/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/309/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/309/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/309/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/309/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/309/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/309/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/309/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/309/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/309/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/309/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/309/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/309/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=309&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2010/02/13/moving-to-a-new-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>

		<media:content url="http://cppkid.files.wordpress.com/2010/02/new-home.jpg?w=200" medium="image">
			<media:title type="html">Home Ownership Keys</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Round Off A Number</title>
		<link>http://cppkid.wordpress.com/2009/02/18/how-to-round-off-a-number/</link>
		<comments>http://cppkid.wordpress.com/2009/02/18/how-to-round-off-a-number/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 12:06:09 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[how to round a float]]></category>
		<category><![CDATA[remove decimals from a number]]></category>
		<category><![CDATA[Round a number]]></category>
		<category><![CDATA[round decimal places]]></category>
		<category><![CDATA[round off float]]></category>
		<category><![CDATA[round off number]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=302</guid>
		<description><![CDATA[Sometimes, it is needed to round off a number to some decimal digits.  Again stringstream comes to help us with the aid of iomanip function setprecision. Following is a sample function to round off a number to a fixed digits. The header files sstream and iomanip are needed for the above. Please note that the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=302&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes, it is needed to round off a number to some decimal digits.  Again <strong>stringstream </strong>comes to help us with the aid of <strong>iomanip</strong> function <strong>setprecision</strong>. Following is a sample function to round off a number to a fixed digits.</p>
<p><pre class="brush: cpp;">
double Round(const double value, const int digits)
{
   stringstream stream;
   // Store the number with required no. of decimal
   // places to stream
   stream &lt;&lt; setprecision(digits) &lt;&lt; value;
   // Convert stream to number
   double roundedValue = 0.0;
   stream &gt;&gt; roundedValue;
   return roundedValue;
}
</pre></p>
<p>The header files <strong>sstream </strong>and <strong>iomanip </strong>are needed for the above.</p>
<p>Please note that the variable value holds the <em>number with original no. of decimal places</em> and <em>digits is the total number of digits needed (including the non-decimal digits) after rounding has taken place</em>.</p>
<p><strong>Round(10.37665, 3)</strong> gives <strong>10.4</strong> and <strong>Round(10.3745, 4)</strong> gives <strong>10.37</strong>.</p>
<h2>Note</h2>
<p>If you want to store the number in scientific notation in stream, you can do</p>
<p><em>stream &lt;&lt;  scientific;</em></p>
<p>For fixed point format, do</p>
<p><em>stream &lt;&lt;  fixed;</em></p>
<br />Posted in C++, VC++ 2005 Tagged: how to round a float, remove decimals from a number, Round a number, round decimal places, round off float, round off number <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/302/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=302&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2009/02/18/how-to-round-off-a-number/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Set Extra Data With Each Row Of A List Box</title>
		<link>http://cppkid.wordpress.com/2009/02/03/how-to-set-extra-data-with-each-row-of-a-list-box/</link>
		<comments>http://cppkid.wordpress.com/2009/02/03/how-to-set-extra-data-with-each-row-of-a-list-box/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 11:23:38 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[adding extra data to CListBox]]></category>
		<category><![CDATA[get data from list box]]></category>
		<category><![CDATA[GetItemData]]></category>
		<category><![CDATA[List box]]></category>
		<category><![CDATA[set data to list box]]></category>
		<category><![CDATA[Set extra data with each row of list box]]></category>
		<category><![CDATA[SetItemData]]></category>
		<category><![CDATA[Store information in CListBox row]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=296</guid>
		<description><![CDATA[We can associate a 32 bit value with each row of a list box. The member function SetItemData() of CListBox can be used for this purpose. The syntax is Parameters nIndex &#8211; Zero based row index of the list box dwItemData &#8211; 32 bit value to be stored in the row The return value will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=296&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We can associate a <strong>32 bit value</strong> with each row of a list box. The member function <strong>SetItemData()</strong> of <strong>CListBox </strong>can be used for this purpose.</p>
<p>The syntax is</p>
<p><pre class="brush: cpp;">
int SetItemData(
   int nIndex,
   DWORD_PTR dwItemData
);
</pre></p>
<h4>Parameters</h4>
<ul>
<li>nIndex &#8211; Zero based row index of the list box</li>
<li>dwItemData &#8211; 32 bit value to be stored in the row</li>
</ul>
<p>The return value will be <strong>LB_ERR</strong>, if an error occurs.<br />
The stored value can be retrieved using <strong>CListBox::GetItemData()</strong>. Again, the syntax is</p>
<pre class="libCScode" style="white-space:pre-wrap;"><pre class="brush: cpp;">
DWORD_PTR GetItemData(
   int nIndex
) const;
</pre>

where nIndex is the zero based index of the list box row, from where we have to get the data.

An example is given below.
<pre class="brush: cpp;">
for (int index = 0; index &lt; myListBox-&gt;GetCount(); ++index)
{
   if (myListBox-&gt;GetItemData(index) == DWORD(-1))
   {
      myListBox-&gt;SetItemData(index, 0);
   }
}
</pre>

The header file <strong>afxwin.h</strong> is needed for the above functions.</pre>
<br />Posted in C++, VC++ 2005 Tagged: adding extra data to CListBox, get data from list box, GetItemData, List box, set data to list box, Set extra data with each row of list box, SetItemData, Store information in CListBox row <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/296/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=296&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2009/02/03/how-to-set-extra-data-with-each-row-of-a-list-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
		<item>
		<title>Issue When Using [] Operator To Access Elements Of A map</title>
		<link>http://cppkid.wordpress.com/2009/01/29/issue-when-using-operator-to-access-elements-of-a-map/</link>
		<comments>http://cppkid.wordpress.com/2009/01/29/issue-when-using-operator-to-access-elements-of-a-map/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 12:24:34 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[access element of a map]]></category>
		<category><![CDATA[get element of a map]]></category>
		<category><![CDATA[map in C++]]></category>
		<category><![CDATA[map issue]]></category>
		<category><![CDATA[problem with map]]></category>
		<category><![CDATA[stl map]]></category>
		<category><![CDATA[[] for map]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=285</guid>
		<description><![CDATA[I had the habit of using [] operator to access elements of a map. For example, if we have map&#60;int, int&#62; myMap, to get the element corresponding to 10, we can use myMap[10]. This is perfectly ok as long as we have an element corresponding to 10. But, what if we don&#8217;t have one corresponding [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=285&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had the habit of using<strong> []</strong> operator to access elements of a map. For example, if we have</p>
<p><strong>map&lt;int, int&gt; myMap</strong>, to get the element corresponding to <strong>10</strong>, we can use</p>
<p><strong>myMap[10]</strong>. This is perfectly ok as long as we have an element corresponding to <strong>10</strong>. But, w<em>hat if we don&#8217;t have one corresponding to 10?</em></p>
<p>There lies the problem. In this situation, <strong>myMap </strong>is already added with a default elemnent corresponding to <strong>10 </strong>(<em>[</em><em>] operator provides no facility to validate if an element exists</em>) and in the above situation, it is <strong>0</strong>. As a result, a new (unwanted) element is added to the map (<em>we can see that the size of map has been incremented by 1</em>).</p>
<p>So a better alternative is to use the <strong>find()</strong> function associated with <strong>map</strong>. It does not add an element and if the element is not found, it will return <strong>map::end()</strong>.</p>
<p>The example given below illustrates this.</p>
<p><pre class="brush: cpp;">
#include &lt;map&gt;
#include &lt;iostream&gt;
using namespace std;

int main()
{
   map myMap;
   cout &lt;&lt; &quot;Size of myMap = &quot; &lt;&lt; myMap.size() &lt;&lt; '\n';   // will be 0
   int content = myMap[0];
   // Now the size of myMap will be 1 as we used the [] operator
   // and the value of content = myMap[0] = 0
   cout &lt;&lt; &quot;Size of myMap = &quot; &lt;&lt; myMap.size() &lt;&lt; '\n';   
   // Instead, if we use find, the size will not change.
   // It will look for the element only.
   map::const_iterator it = myMap.find(1);
   // Here the element has not been found. So it = myMap.end()
   cout &lt;&lt; &quot;Size of myMap = &quot; &lt;&lt; myMap.size() &lt;&lt; '\n';   // will be 1 only 
   return 0;   
}
</pre></p>
<p>So the best practice is to avoid [] operator for accessing individual elements of a map.</p>
<br />Posted in C++, VC++ 2005 Tagged: access element of a map, get element of a map, map in C++, map issue, problem with map, stl map, [] for map <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/285/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=285&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2009/01/29/issue-when-using-operator-to-access-elements-of-a-map/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Watch A Variable Even After Its Scope Is Over</title>
		<link>http://cppkid.wordpress.com/2009/01/19/how-to-watch-a-variable-even-after-its-scope-is-over/</link>
		<comments>http://cppkid.wordpress.com/2009/01/19/how-to-watch-a-variable-even-after-its-scope-is-over/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 13:04:23 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[how to watch a variable]]></category>
		<category><![CDATA[Watch a variable]]></category>
		<category><![CDATA[watch a variable after its scope is over]]></category>
		<category><![CDATA[watch a variable througout the program]]></category>
		<category><![CDATA[watch window]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=263</guid>
		<description><![CDATA[Noramally, the value of a variable declared in a function can be seen in the watch window only when the control is inside that function itself (eg. When the above function calles a new function and if we step into the new function.) . Let&#8217;s discuss an example. In the above example, if I put [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=263&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Noramally, the value of a variable declared in a function can be seen in the watch window only when the control is inside that function itself (eg. When the above function calles a new function and if we step into the new function.) . Let&#8217;s discuss an example.</p>
<p><pre class="brush: cpp;">
void SomeFunction()
{
   int myVariable = 20;
}
int main()
{
   int myVariable = 10;
   SomeFunction();
   return 0;   
}
</pre></p>
<p>In the above example, if I put a break point in the function main after the statement <strong>int myVariable = 10;</strong> I can see the value of myVariable in the watch window as follows.</p>
<p style="text-align:center;"><a href="http://cppkid.files.wordpress.com/2009/01/break-point-in-main4.jpg"><img class="alignnone size-full wp-image-277" title="break-point-in-main4" src="http://cppkid.files.wordpress.com/2009/01/break-point-in-main4.jpg?w=450&#038;h=281" alt="break-point-in-main4" width="450" height="281" /></a></p>
<p>Now, if I put another break point in <strong>SomeFunction()</strong> after the statement <strong>int myVariable = 20;</strong>, when th execution flow reaches there, the watch window will show the value of myariable as <strong>20</strong> only.</p>
<p>So we have lost the value of <strong>myVariable</strong> declared in <strong>main()</strong>, eventhogh it lifetime is not over now.</p>
<h3>How To Add a Permanent watch</h3>
<p>We can still view the value of myVariable declared in <strong>main(</strong>) inside the function S<strong>omeFunction()</strong>. For this, we will use the <strong>address</strong> of memory location (rather than the variable name) in which <strong>myVariable</strong> has been declared in <strong>main()</strong>. We can view the contents of this memory location as long as it has life in the program.</p>
<p>When the control reaches the break point in <strong>main()</strong>, take the address of <strong>myVariable</strong> using the <strong>&amp;</strong> operator. Now we have a valid memory location address (a pointer). Still, it can be a raw pointer. So cast it to the correct type (int, in this case, as <strong>myVariable</strong> is of type integer) as</p>
<p><em>(int*)(address of myVariable)</em></p>
<p style="text-align:center;"><a href="http://cppkid.files.wordpress.com/2009/01/adding-a-watch.jpg"></a></p>
<p><a href="http://cppkid.files.wordpress.com/2009/01/adding-a-watch1.jpg"><img class="aligncenter size-full wp-image-281" title="adding-a-watch1" src="http://cppkid.files.wordpress.com/2009/01/adding-a-watch1.jpg?w=450&#038;h=281" alt="adding-a-watch1" width="450" height="281" /></a>Now see how the watch window shows the value we have stored, when the control reaches the second break point.</p>
<p style="text-align:center;"><a href="http://cppkid.files.wordpress.com/2009/01/watching-the-old-variable1.jpg"><img class="aligncenter size-full wp-image-282" title="watching-the-old-variable1" src="http://cppkid.files.wordpress.com/2009/01/watching-the-old-variable1.jpg?w=450&#038;h=281" alt="watching-the-old-variable1" width="450" height="281" /></a><a href="http://cppkid.files.wordpress.com/2009/01/watching-the-old-variable.jpg"></a></p>
<br />Posted in C++, VC++ 2005 Tagged: how to watch a variable, Watch a variable, watch a variable after its scope is over, watch a variable througout the program, watch window <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/263/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/263/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=263&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2009/01/19/how-to-watch-a-variable-even-after-its-scope-is-over/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>

		<media:content url="http://cppkid.files.wordpress.com/2009/01/break-point-in-main4.jpg" medium="image">
			<media:title type="html">break-point-in-main4</media:title>
		</media:content>

		<media:content url="http://cppkid.files.wordpress.com/2009/01/adding-a-watch1.jpg" medium="image">
			<media:title type="html">adding-a-watch1</media:title>
		</media:content>

		<media:content url="http://cppkid.files.wordpress.com/2009/01/watching-the-old-variable1.jpg" medium="image">
			<media:title type="html">watching-the-old-variable1</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Handle new Operator Failure</title>
		<link>http://cppkid.wordpress.com/2009/01/15/how-to-handle-new-operator-failure/</link>
		<comments>http://cppkid.wordpress.com/2009/01/15/how-to-handle-new-operator-failure/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 05:46:35 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[bad_alloc]]></category>
		<category><![CDATA[handle memory allocation failure]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[new fails]]></category>
		<category><![CDATA[operator new]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=255</guid>
		<description><![CDATA[new operator is used to allocate memory in C++. Though it is rare that a modern day computer is not able to allocate memory for our program, still there may be situations where we have to face situations where the new operator fails. The function set_new_handler will divert the flow to a user function when the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=255&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><em>new</em></strong> operator is used to allocate memory in C++. Though it is rare that a modern day computer is not able to allocate memory for our program, still there may be situations where we have to face situations where the new operator fails. The function <strong>set_new_handler</strong> will divert the flow to a user function when the new operator fails. A simple example is given below.</p>
<p><pre class="brush: cpp;">
#include &lt;iostream&gt;
using namespace std;

// Function to be called when the new operator fails
void NewHandler()
{
   cout &lt;&lt; &quot;Out of memory&quot; &lt;&lt; '\n';
   exit(0);
}
 
int main()
{
   // Set the function to be called when new operator fails
   set_new_handler(NewHandler);
   while (true)
   {
      new int[50000000];   // Hope this will fail after a few iterations
      cout &lt;&lt; &quot;Successful so far&quot; &lt;&lt; '\n';
   }
   return 0;
}
</pre></p>
<p>In the above example, the function NewHandler() will be called when the memory allocation using new operator fails.</p>
<h3><strong>Some Background Info</strong></h3>
<p><strong>set_new_handle</strong>r will store the function <strong>NewHandler()</strong> in a static <a href="http://msdn.microsoft.com/en-us/library/we2zys4d(VS.80).aspx" target="_blank">new handler</a> pointer. This new handler is used by operator <em><strong>new</strong></em>.</p>
<br />Posted in C++, VC++ 2005 Tagged: bad_alloc, handle memory allocation failure, new, new fails, operator new <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=255&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2009/01/15/how-to-handle-new-operator-failure/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Get The Screen Resolution In Pixels</title>
		<link>http://cppkid.wordpress.com/2009/01/07/how-to-get-the-screen-resolution-in-pixels/</link>
		<comments>http://cppkid.wordpress.com/2009/01/07/how-to-get-the-screen-resolution-in-pixels/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 08:40:11 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[current screen resolution]]></category>
		<category><![CDATA[get desktop resolution]]></category>
		<category><![CDATA[Get screen resolution]]></category>
		<category><![CDATA[resolution]]></category>
		<category><![CDATA[resolution in pixel]]></category>
		<category><![CDATA[VC++]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=246</guid>
		<description><![CDATA[The function GetWindowRect(), defined in WinUser.h, is able to give the current screen resolution. The declaration of GetWindowRect() is We can give a handle to the current desktop window to the above function as input. A sample implementation for getting the current screen resolution is given below. Posted in C++, VC++ 2005 Tagged: C++, current [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=246&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The function <strong>GetWindowRect()</strong>, defined in <strong>WinUser.h</strong>, is able to give the current screen resolution. The declaration of <strong>GetWindowRect()</strong> is</p>
<p><pre class="brush: cpp;">

BOOL
WINAPI
GetWindowRect(
    __in HWND hWnd,
    __out LPRECT lpRect);

</pre></p>
<p>We can give a handle to the current desktop window to the above function as input. A sample implementation for getting the current screen resolution is given below.</p>
<p><pre class="brush: cpp;">

#include &quot;wtypes.h&quot;
#include &lt;iostream&gt;
using namespace std;

// Get the horizontal and vertical screen sizes in pixel
void GetDesktopResolution(int&amp; horizontal, int&amp; vertical)
{
   RECT desktop;
   // Get a handle to the desktop window
   const HWND hDesktop = GetDesktopWindow();
   // Get the size of screen to the variable desktop
   GetWindowRect(hDesktop, &amp;desktop);
   // The top left corner will have coordinates (0,0)
   // and the bottom right corner will have coordinates
   // (horizontal, vertical)
   horizontal = desktop.right;
   vertical = desktop.bottom;
}

int main()
{       
   int horizontal = 0;
   int vertical = 0;
   GetDesktopResolution(horizontal, vertical);
   cout &lt;&lt; horizontal &lt;&lt; '\n' &lt;&lt; vertical &lt;&lt; '\n';
   return 0;
}

</pre></p>
<br />Posted in C++, VC++ 2005 Tagged: C++, current screen resolution, get desktop resolution, Get screen resolution, resolution, resolution in pixel, VC++ <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/246/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=246&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2009/01/07/how-to-get-the-screen-resolution-in-pixels/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Call A Managed Dll From Unmanaged Code</title>
		<link>http://cppkid.wordpress.com/2009/01/02/how-to-call-a-managed-dll-from-unmanaged-code/</link>
		<comments>http://cppkid.wordpress.com/2009/01/02/how-to-call-a-managed-dll-from-unmanaged-code/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 11:10:50 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[call c# from C++]]></category>
		<category><![CDATA[call CLR compiled code in C++]]></category>
		<category><![CDATA[call managed code from unmanaged code]]></category>
		<category><![CDATA[Call Managed DLL from unmanaged code]]></category>
		<category><![CDATA[managed in unmananged]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=237</guid>
		<description><![CDATA[I here illustrate how a dll written in C# is called in C++ (without CLR). Make a DLL in C# Let&#8217;s make a small dll (MathLibrary.dll) in C# which provides a public API for adding two numbers. Start Visual Studio, start a new project in Visual C# and select the type of the project as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=237&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I here illustrate how a dll written in C# is called in C++ (without CLR).</p>
<h3>Make a DLL in C#</h3>
<p>Let&#8217;s make a small dll (<em>MathLibrary.dll</em>) in <strong>C#</strong> which provides a public API for adding two numbers. Start Visual Studio, start a new project in Visual C# and select the type of the project as class library. This is how my code for DLL looks like.</p>
<p><pre class="brush: cpp;">

using System;
using System.Collections.Generic;
using System.Text;

namespace MathLibrary
{
   public interface IAddClass
   {
      int Add(int a, int b);
   }
   public class CAddClass : IAddClass
   {
      public int Add(int a, int b)
      {
         return a+b;
      }
   }
}

</pre></p>
<p>It has a namespace <strong>MathLibrary</strong> which contains an interface <strong>IAddClass</strong> and its implementation <strong>CAddClass.</strong> The public API <strong>Add(int a, int b)</strong> is provided which can add two numbers supplied.</p>
<p>We have to attach a key file to our DLLl. To generate the key file, go to Visual Studio command prompt (From Start menu &#8211;&gt; Programs &#8211;&gt; Microsoft Visual Studio 2005 &#8211;&gt; Visual Studio Tools). n the command prompt, type</p>
<p><em><strong><span class="userInput">sn.exe -k MyKeyFile.SNK</span></strong></em></p>
<p><span class="userInput">You can see that <strong>MyKeyFile.SNK</strong> is generated in the visual studio directory (the command prompt will display where it has been generated). Copy it to the source directory of the dll.  Now edit the AssemblyInfo.cs in visual studio and add/edit the following lines.</span></p>
<p><span class="userInput"> <pre class="brush: cpp;">
[assembly: ComVisible(true)]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile(&quot;MyKeyFile.SNK&quot;)]
</pre></p>
<p></span></p>
<p><span class="userInput">Make sure that <strong>MyKeyFile.SNK</strong> is in the correct path specified.</span></p>
<p><span class="userInput">Now you can build the DLL (or press Ctrl + Shift + B).</span></p>
<p><span class="userInput">Copy the dll to the directory of the source (C++ program withour CLR option) from where it is to be called.</span></p>
<h3><span class="userInput">Register the DLL</span></h3>
<p><span class="userInput">Now you have to register the managed dll for using in the unmanaged C++ code. Again take the visual studio command prompt and enter the following command.</span></p>
<p><em><strong><span class="userInput">RegAsm.exe [including full path] MathLibrary.dll /tlb:MathLibrary.tlb             /codebase</span></strong></em></p>
<p><span class="userInput">We have generated a TLB file, which  contains the type library of different types used in the DLL. </span><span class="userInput">The dll is now registered and ready for use in unmanaged code.</span></p>
<h3><span class="userInput">Call the DLL from Unmanaged code</span></h3>
<p><span class="userInput">The .NET component (dll) can be used as a COM in unmanaged code. So a sample code is provided below which uses the managed DLL as COM.</span></p>
<p><span class="userInput"> <pre class="brush: cpp;">
#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;

// Import the type library in DLL
#import &quot;MathLibrary.tlb&quot; raw_interfaces_only

using namespace MathLibrary;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
   // Initialize the COM interface
   HRESULT hr = CoInitialize(NULL);
   // Make a smart pointer to the IAddClass interface in DLL
   IAddClassPtr pIAddClass(__uuidof(CAddClass));   
   // Add two numbers using the ADD API
   long result = 0;
   hr = pIAddClass-&gt;Add(10, 20, &amp;result);
   // Release the COM interface
   CoUninitialize();
   // Display the results
   cout &lt;&lt; result &lt;&lt; '\n';  
   return 0;
}
</pre></p>
<p></span></p>
<p><span class="userInput"><br />
</span></p>
<br />Posted in C++, VC++ 2005 Tagged: call c# from C++, call CLR compiled code in C++, call managed code from unmanaged code, Call Managed DLL from unmanaged code, managed in unmananged <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/237/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=237&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2009/01/02/how-to-call-a-managed-dll-from-unmanaged-code/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Increment/Decrement A Variable In A Thread Safe Manner</title>
		<link>http://cppkid.wordpress.com/2008/12/31/how-to-incrementdecrement-a-variable-in-a-thread-safe-manner/</link>
		<comments>http://cppkid.wordpress.com/2008/12/31/how-to-incrementdecrement-a-variable-in-a-thread-safe-manner/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 03:30:46 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[Thread]]></category>
		<category><![CDATA[Thread safe]]></category>
		<category><![CDATA[Thread safe decrement]]></category>
		<category><![CDATA[thread safe increment]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=228</guid>
		<description><![CDATA[Sometimes it will be necessary to increment or decrement a variable in a atomic manner so that no other thread can affect it while being incremented/decremented. The complex mutexes and critical sections can do the trick. Still, there is a single line API which does the same and it is LONG InterlockedIncrement(LONG volatile* Addend) (InterlockedDecrement [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=228&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes it will be necessary to increment or decrement a variable in a atomic manner so that no other thread can affect it while being incremented/decremented. The complex mutexes and critical sections can do the trick. Still, there is a single line API which does the same and it is</p>
<p><strong>LONG InterlockedIncrement(LONG volatile* Addend)</strong></p>
<p>(<strong>InterlockedDecrement</strong> for decrementing the value).</p>
<p>For example,</p>
<pre><strong><em>LONG myNo = 10;</em></strong>
<strong><em>LONG returnValue = InterlockedIncrement(&amp;myNo);</em></strong></pre>
<p>will make</p>
<p>myNO = 11 and returnValue = 11.</p>
<br />Posted in C++, VC++ 2005 Tagged: Thread, Thread safe, Thread safe decrement, thread safe increment <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/228/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=228&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2008/12/31/how-to-incrementdecrement-a-variable-in-a-thread-safe-manner/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Get The Time Elapsed Since The System Was Started</title>
		<link>http://cppkid.wordpress.com/2008/12/30/how-to-get-the-time-elapsed-since-the-system-was-started/</link>
		<comments>http://cppkid.wordpress.com/2008/12/30/how-to-get-the-time-elapsed-since-the-system-was-started/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 11:29:15 +0000</pubDate>
		<dc:creator>cppkid</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC++ 2005]]></category>
		<category><![CDATA[Get time]]></category>
		<category><![CDATA[get time since computer was started]]></category>
		<category><![CDATA[GetTickCount]]></category>

		<guid isPermaLink="false">http://cppkid.wordpress.com/?p=225</guid>
		<description><![CDATA[The function GetTickCount() (defined in WinBase.h) returns the no. of milliseconds elapsed since the computer was started. The returned value is DWORD. So the above call may malfunction if the system has been up continuously for 49.7 days (as DWORD is only 32 bit). You can use the function GetTickCount64(), which returns ULONGLONG,  to overcome [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=225&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The function <strong>GetTickCount()</strong> (defined in WinBase.h) returns the no. of milliseconds elapsed since the computer was started.</p>
<p>The returned value is <strong>DWORD</strong>. So the above call may malfunction if the system has been up continuously for <strong>49.7</strong> days (as DWORD is only 32 bit). You can use the function <strong>GetTickCount64()</strong>, which returns <strong>ULONGLONG</strong>,  to overcome this problem.</p>
<br />Posted in C++, VC++ 2005 Tagged: Get time, get time since computer was started, GetTickCount <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cppkid.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cppkid.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cppkid.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cppkid.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cppkid.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cppkid.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cppkid.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cppkid.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cppkid.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cppkid.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cppkid.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cppkid.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cppkid.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cppkid.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cppkid.wordpress.com&amp;blog=3330536&amp;post=225&amp;subd=cppkid&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cppkid.wordpress.com/2008/12/30/how-to-get-the-time-elapsed-since-the-system-was-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4eb32b408e5ffe8474e9834e4879425b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">cppkid</media:title>
		</media:content>
	</item>
	</channel>
</rss>
