<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>c-programming &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/c-programming/</link>
	<description>Feed of posts on WordPress.com tagged "c-programming"</description>
	<pubDate>Mon, 28 May 2012 23:08:39 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Vector]]></title>
<link>http://cppacademy.wordpress.com/2012/03/29/vector/</link>
<pubDate>Thu, 29 Mar 2012 19:16:49 +0000</pubDate>
<dc:creator>cppacademy</dc:creator>
<guid>http://cppacademy.wordpress.com/2012/03/29/vector/</guid>
<description><![CDATA[The standard library provides a type, named vector, which is a sequence container.  A vector is dyna]]></description>
<content:encoded><![CDATA[<p>The standard library provides a type, named vector, which is a sequence container.  A vector is dynamic, thus they are implemented as dynamic arrays; they can grow when needed to accommodate additional values, and allow us to access individual values efficiently.</p>
<p>A vector is declared like so (Although the number of elements is optional):</p>
<p><pre class="brush: cpp;">
vector&#60;type&#62; variable_name (number_of_elements);
</pre></p>
<p>Declaring a vector with integers</p>
<p><pre class="brush: cpp;">
vector someInt (5);      // Declares a vector of 5 integers.
</pre></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Data Types in C]]></title>
<link>http://opensourcecodechef.wordpress.com/2012/03/28/data-types-in-c/</link>
<pubDate>Wed, 28 Mar 2012 17:58:51 +0000</pubDate>
<dc:creator>opensourcecodechef</dc:creator>
<guid>http://opensourcecodechef.wordpress.com/2012/03/28/data-types-in-c/</guid>
<description><![CDATA[]]></description>
<content:encoded><![CDATA[<p><a href="http://opensourcecodechef.files.wordpress.com/2012/03/977725_f496.jpg"><img src="http://opensourcecodechef.files.wordpress.com/2012/03/977725_f496.jpg" alt="" title="977725_f496" width="496" height="360" class="alignnone size-full wp-image-85" /></a><br />
<a href="http://opensourcecodechef.files.wordpress.com/2012/03/977729_f496.jpg"><img src="http://opensourcecodechef.files.wordpress.com/2012/03/977729_f496.jpg" alt="" title="977729_f496" width="496" height="87" class="alignnone size-full wp-image-86" /></a><br />
<a href="http://opensourcecodechef.files.wordpress.com/2012/03/977747_f496.jpg"><img src="http://opensourcecodechef.files.wordpress.com/2012/03/977747_f496.jpg" alt="" title="977747_f496" width="496" height="87" class="alignnone size-full wp-image-87" /></a><br />
<a href="http://opensourcecodechef.files.wordpress.com/2012/03/978945.png"><img src="http://opensourcecodechef.files.wordpress.com/2012/03/978945.png" alt="" title="978945" width="645" height="257" class="alignnone size-full wp-image-88" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[How to write a lab report of Programming?]]></title>
<link>http://alaminopu.wordpress.com/2012/03/28/how-to-write-a-lab-report-of-programming/</link>
<pubDate>Wed, 28 Mar 2012 17:09:25 +0000</pubDate>
<dc:creator>Md. Al-Amin Opu</dc:creator>
<guid>http://alaminopu.wordpress.com/2012/03/28/how-to-write-a-lab-report-of-programming/</guid>
<description><![CDATA[Suppose, you are given a problem set. Choose one by one and write corresponding lab report. Consider]]></description>
<content:encoded><![CDATA[Suppose, you are given a problem set. Choose one by one and write corresponding lab report. Consider]]></content:encoded>
</item>
<item>
<title><![CDATA[Lessons on development of 64-bit C/C++ applications]]></title>
<link>http://francescodifusco.wordpress.com/2012/03/28/lessons-on-development-of-64-bit-cc-applications/</link>
<pubDate>Wed, 28 Mar 2012 13:30:47 +0000</pubDate>
<dc:creator>francescodifusco</dc:creator>
<guid>http://francescodifusco.wordpress.com/2012/03/28/lessons-on-development-of-64-bit-cc-applications/</guid>
<description><![CDATA[Lessons on development of 64-bit C/C++ applications via Lessons on development of 64-bit C/C++ appli]]></description>
<content:encoded><![CDATA[<p>Lessons on development of 64-bit C/C++ applications</p>
<p>via <a href="http://www.viva64.com/en/l/">Lessons on development of 64-bit C/C++ applications</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[A Collection of Examples of 64-bit Errors in Real Programs]]></title>
<link>http://francescodifusco.wordpress.com/2012/03/28/a-collection-of-examples-of-64-bit-errors-in-real-programs/</link>
<pubDate>Wed, 28 Mar 2012 13:29:37 +0000</pubDate>
<dc:creator>francescodifusco</dc:creator>
<guid>http://francescodifusco.wordpress.com/2012/03/28/a-collection-of-examples-of-64-bit-errors-in-real-programs/</guid>
<description><![CDATA[&nbsp; A Collection of Examples of 64-bit Errors in Real Programs.]]></description>
<content:encoded><![CDATA[<p>&#160;</p>
<p style="text-align:center;"><a href="http://www.viva64.com/en/a/0065/print/"><img src='http://francescodifusco.files.wordpress.com/2012/03/image1.png' alt='' /></a></p>
<p><a href="http://www.viva64.com/en/a/0065/print/">A Collection of Examples of 64-bit Errors in Real Programs</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Integrate Video Streaming Into Your C/C++ Application Using Nex Gen Media Server API | HowtoForge - Linux Howtos and Tutorials]]></title>
<link>http://francescodifusco.wordpress.com/2012/03/28/integrate-video-streaming-into-your-cc-application-using-nex-gen-media-server-api-howtoforge-linux-howtos-and-tutorials/</link>
<pubDate>Wed, 28 Mar 2012 05:26:29 +0000</pubDate>
<dc:creator>francescodifusco</dc:creator>
<guid>http://francescodifusco.wordpress.com/2012/03/28/integrate-video-streaming-into-your-cc-application-using-nex-gen-media-server-api-howtoforge-linux-howtos-and-tutorials/</guid>
<description><![CDATA[Integrate Video Streaming Into Your C/C++ Application Using Nex Gen Media Server API via Integrate V]]></description>
<content:encoded><![CDATA[<p>Integrate Video Streaming Into Your C/C++ Application Using Nex Gen Media Server API</p>
<p>via <a href="http://www.howtoforge.com/integrate-video-streaming-into-your-c-c-plusplus-application-using-nex-gen-media-server-api">Integrate Video Streaming Into Your C/C++ Application Using Nex Gen Media Server API &#124; HowtoForge &#8211; Linux Howtos and Tutorials</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Pointers &amp; Strings Tutorial ]]></title>
<link>http://bahen2175.com/2012/03/27/pointers-strings-tutorial-2/</link>
<pubDate>Tue, 27 Mar 2012 18:35:52 +0000</pubDate>
<dc:creator>saltedcaramel2011</dc:creator>
<guid>http://bahen2175.com/2012/03/27/pointers-strings-tutorial-2/</guid>
<description><![CDATA[int i = 57; (okay) float z; (okay) int *n; (okay) *n = 38; (error) &#8212;&#8211;&gt; must be given ]]></description>
<content:encoded><![CDATA[<p>int i = 57; (okay)<br />
float z; (okay)<br />
int *n; (okay)<br />
*n = 38; (error) &#8212;&#8211;&#62; must be given an address first in order to change the value stored at the address<br />
n = 38; (error)<br />
&#38;n = 38; (error)<br />
n = &#38;i; (okay)<br />
*n = 38; (okay)<br />
++*n; (okay)</p>
<p>Array a: &#8220;a&#8221; itself is a pointer (the address of the first element)<br />
int a[10];<br />
int *ptr;<br />
ptr = &#38;a[0];<br />
ptr = a;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Using]]></title>
<link>http://cppacademy.wordpress.com/2012/03/27/using/</link>
<pubDate>Tue, 27 Mar 2012 17:28:22 +0000</pubDate>
<dc:creator>cppacademy</dc:creator>
<guid>http://cppacademy.wordpress.com/2012/03/27/using/</guid>
<description><![CDATA[The using keyword tells our program to use specific, or every name in a namespace. For example: usin]]></description>
<content:encoded><![CDATA[<p>The <span><strong>using</strong></span> keyword tells our program to use specific, or every name in a <a title="Namespace" href="http://cppacademy.wordpress.com/2012/03/27/namespace/"><strong><span>namespace</span></strong></a>.</p>
<p><strong>For example:</strong></p>
<p><pre class="brush: cpp;">
using namespace std;
</pre></p>
<p><strong><span>using</span></strong> will take everything that is in the <em>std</em> <strong><span>library</span></strong> and allow you to use it within your code.</p>
<p><strong>Another example:</strong></p>
<p><pre class="brush: cpp;">
using std::cout;
</pre></p>
<p><span><strong>using</strong> </span>will now only take <em>&#8216;cout</em>&#8216;, and only <em>&#8216;cout&#8217;</em> from the <em>std</em> <span><strong>library</strong></span>.</p>
<p>Only using the parts of a library that we need keeps our program free from unnecessary bloating and enables it to run more smoothly.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Namespace]]></title>
<link>http://cppacademy.wordpress.com/2012/03/27/namespace/</link>
<pubDate>Tue, 27 Mar 2012 17:03:53 +0000</pubDate>
<dc:creator>cppacademy</dc:creator>
<guid>http://cppacademy.wordpress.com/2012/03/27/namespace/</guid>
<description><![CDATA[A namespace is a container in which you can group entities such functions, objects and classes.  A n]]></description>
<content:encoded><![CDATA[<p align="JUSTIFY"><span style="font-family:Arial,sans-serif;">A <strong><span>namespace</span></strong> is a container in which you can group entities such <strong><span>functions</span></strong>, <strong><span>objects</span></strong> and<span><strong> classes</strong></span>.  A <strong><span>namespace</span></strong> uses a prefix which avoids possible conflicts if you happen to use a<span><strong> function</strong></span> with the same name later on.</span></p>
<p align="JUSTIFY"><strong><span style="font-family:Arial,sans-serif;">For example:</span></strong></p>
<p><pre class="brush: cpp;">
namespace myVar
{
    int a, b;
}
</pre></p>
<p>which you can then call the namespace with:</p>
<p><pre class="brush: cpp;">
myVar::a
</pre></p>
<p><strong>Also see</strong>: <a title="Using" href="http://cppacademy.wordpress.com/2012/03/27/using/"><span>using</span></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C program to Reverse a number]]></title>
<link>http://opensourcecodechef.wordpress.com/2012/03/27/c-program-to-reverse-a-number/</link>
<pubDate>Tue, 27 Mar 2012 02:57:22 +0000</pubDate>
<dc:creator>opensourcecodechef</dc:creator>
<guid>http://opensourcecodechef.wordpress.com/2012/03/27/c-program-to-reverse-a-number/</guid>
<description><![CDATA[C Program to reverse a number :- This program reverse the number entered by the user and then prints]]></description>
<content:encoded><![CDATA[<p>C Program to reverse a number :- This program reverse the number entered by the user and then prints the reversed number on the screen. For example if user enter 123 as input then 321 is printed as output. In our program we use modulus(%) operator to obtain the digits of a number. To invert number look at it and write it from opposite direction or the output of code is a number obtained by writing original number from right to left.</p>
<p><strong>C programming code</strong></p>
<p>#include&#60;stdio.h&#62;</p>
<p>main()<br />
{<br />
   int n, reverse = 0;</p>
<p>   printf(&#8220;Enter a number to reverse\n&#8221;);<br />
   scanf(&#8220;%d&#8221;,&#38;n);</p>
<p>   while( n != 0 )<br />
   {<br />
      reverse = reverse * 10;<br />
      reverse = reverse + n%10;<br />
      n = n/10;<br />
   }</p>
<p>   printf(&#8220;Reverse of entered number is = %d\n&#8221;, reverse);</p>
<p>   return 0;<br />
}</p>
<p><strong>Output of program:</strong></p>
<p><a href="http://opensourcecodechef.files.wordpress.com/2012/03/reverse-number.png"><img src="http://opensourcecodechef.files.wordpress.com/2012/03/reverse-number.png?w=300&h=51" alt="" title="reverse number" width="300" height="51" class="alignnone size-medium wp-image-74" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[4 AM On a Monday Morning]]></title>
<link>http://bahen2175.com/2012/03/26/4-am-on-a-monday-morning-6/</link>
<pubDate>Mon, 26 Mar 2012 08:11:24 +0000</pubDate>
<dc:creator>saltedcaramel2011</dc:creator>
<guid>http://bahen2175.com/2012/03/26/4-am-on-a-monday-morning-6/</guid>
<description><![CDATA[Everything seems like the same. Monday morning. The clock hand niftily points at four. A lamp, a pen]]></description>
<content:encoded><![CDATA[<p>Everything seems like the same. Monday morning. The clock hand niftily points at four. A lamp, a pen &#8212; the room is quiet, dark and serene. But I can hardly appreciate the night&#8217;s tranquility without you here. I&#8217;m sorry, honey, for what I&#8217;ve said earlier tonight. I really meant to tell it as a joke and I yearn for your forgiveness.</p>
<p>Honey. I miss you and I wish I could tell you how grateful I am, everyday, for being able to be with you, to hold your hand, and to plan out our future together as a family. You&#8217;re truly the best thing that has ever been mine.</p>
<p>P.S.: Our APS 106 project is almost done with only a few tweaks to be made. The printing functions and the log files are looking great. The two concerns left for now are the computer play array sizes and the number of invalid paths. I&#8217;m so proud of us <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Euclidean algorithm]]></title>
<link>http://daemoneye.wordpress.com/2012/03/25/euclidean-algorithm/</link>
<pubDate>Sun, 25 Mar 2012 14:08:33 +0000</pubDate>
<dc:creator>daemoneye</dc:creator>
<guid>http://daemoneye.wordpress.com/2012/03/25/euclidean-algorithm/</guid>
<description><![CDATA[So I went to try and solve the Euclidean algorithm not too long ago using C++ and one recursive func]]></description>
<content:encoded><![CDATA[<p>So I went to try and solve the <a href="http://en.wikipedia.org/wiki/Euclidean_algorithm">Euclidean algorithm</a> not too long ago using C++ and one recursive function.  The Euclidean algorithm is one way to find the greatest common divisor of two integer numbers.  I ask that if you use the code, please keep my name in the header comment.  The code can be found <a href="http://stu.wccnet.edu/~kwolter/code_examples/gcd.cpp">here</a>.  I had to post it off wordpress, as it was not displaying all of the code.  *grumbles*</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Debugging C/C++ and CPython using GDB 7's new Python extension support]]></title>
<link>http://misspent.wordpress.com/2012/03/24/debugging-cc-and-cpython-using-gdb-7s-new-python-extension-support/</link>
<pubDate>Sat, 24 Mar 2012 09:40:05 +0000</pubDate>
<dc:creator>abingham</dc:creator>
<guid>http://misspent.wordpress.com/2012/03/24/debugging-cc-and-cpython-using-gdb-7s-new-python-extension-support/</guid>
<description><![CDATA[I&#8217;ve recently been looking into ways to improve my debugging experience with mixed Python and ]]></description>
<content:encoded><![CDATA[<p>I&#8217;ve recently been looking into ways to improve my debugging experience with mixed Python and C/C++ programs. I spend a fair amount of time working on systems built using both languages in tandem, and the tools available for debugging across the languages have historically been very limited. Often, logging and/or intimate knowledge of the Python C-API (and, in my case, boost.python) were the primary tools available.</p>
<p>I was naturally very excited, then, when GDB 7 introduced support for extension via Python. This seemed like an obvious step towards a &#8220;unified&#8221; debugging environment, one where I could step naturally between the languages, set breakpoints, etc. This new GDB feature doesn&#8217;t solve the problem directly, but it opens the door for more sophisticated extensions to GDB than were previously practical.</p>
<p>Building on this new GDB feature, recent Python source releases include GDB extensions as a build product. That is, starting at around python-3.2, when you build Python from source one of the build products is a set of GDB extensions that make it possible to do very natural debugging of Python from inside GDB. These extensions allow you, for example, to step up and down the Python call stack, display frame information (locals), and so forth. And this can be done while <em>also</em> navigating the base C call stack. This provides a very intuitive and productive debugging environment for anyone working across the two runtime environment.</p>
<p><em>edit:</em> It was pointed out on <a href="http://redd.it/rbd1y">reddit</a> that gdb&#8217;s embedded Python interpreter has been around since 2009 and is thus not particularly new.</p>
<h2>GDB 7&#8242;s Python extension system</h2>
<p>What exactly is GDB&#8217;s new Python extension system? Broadly speaking, it&#8217;s a way to script GDB using Python rather than GDB&#8217;s own internal language. From around version 7 onward, GDB embeds a Python interpreter that you can invoke from the prompt and from scripts. For example:</p>
<p><pre class="brush: plain;">
(gdb) python
&#62;import sys
</pre></p>
<p>To support writing extensions, you can import the module &#8220;gdb&#8221; from this embedded interpreter. This module provides access and hooks into GDB so that you can control it via Python scripts. You can read all about this Python extension support in <a href="http://sourceware.org/gdb/download/onlinedocs/gdb/Python.html#Python">GDB&#8217;s documentation</a>.</p>
<p>This new facility has been used to implement, for example, <a href="http://sourceware.org/gdb/wiki/STLSupport">pretty printers for STL containers</a>. But in this article we&#8217;re interested in improving the CPython debugging experience, so we&#8217;ll cover that in the next section.</p>
<h2>Python&#8217;s GDB extensions</h2>
<p>As previously mentioned, recent Python source releases (from about 3.2 onward) include a new build product: a GDB Python extension that helps you debug Python. What does this mean? The extension encodes knowledge about CPython&#8217;s actual C-level structures, function frame implementation, PyObject, and so forth. It hooks this knowledge into GDB so that you can interrogate the CPython runtime at the Python source level rather than the CPython level.</p>
<p>For example, here are some partial stack traces from a break point inside a C extension module. The first one is a raw stack trace showing the guts of CPython execution:</p>
<p><pre class="brush: plain;">
(gdb) bt
 #0 get_value () at some_lib.c:1
 #1 0x00007ffff686348c in ffi_call_unix64 () at /home/abingham/src/Python-3.2/Modules/_ctypes/libffi/src/x86/unix64.S:75
 #2 0x00007ffff6862bc3 in ffi_call (cif=0x7fffffffde40, fn=, rvalue=, avalue=)
 at /home/abingham/src/Python-3.2/Modules/_ctypes/libffi/src/x86/ffi64.c:485
 #3 0x00007ffff68574ec in _call_function_pointer (pProc=, argtuple=, flags=,
 argtypes=, restype=, checker=) at /home/abingham/src/Python-3.2/Modules/_ctypes/callproc.c:808
 #4 _ctypes_callproc (pProc=, argtuple=, flags=, argtypes=,
 restype=, checker=) at /home/abingham/src/Python-3.2/Modules/_ctypes/callproc.c:1151
 #5 0x00007ffff684f823 in PyCFuncPtr_call (self=0x7ffff7e3a600, inargs=0x7ffff7f87050, kwds=)
 at /home/abingham/src/Python-3.2/Modules/_ctypes/_ctypes.c:3766
 #6 0x00000000004db737 in PyObject_Call (func=0x7ffff7e3a600, arg=0x506417, kw=0x4) at Objects/abstract.c:2149
 #7 0x00000000004658d4 in do_call (f=0x987d20, throwflag=) at Python/ceval.c:4095
</pre></p>
<p>The next one shows the Python debugging extension getting loaded, followed by a new stack trace. This new trace is still at the C source level, but you&#8217;ll notice that many of the CPython calls are annotated with Python source level information (e.g. file names, line numbers, etc.):</p>
<p><pre class="brush: plain;">
 (gdb) python
 &#62;import python3_2_gdb
 &#62;(gdb) bt
 #0 get_value () at some_lib.c:1
 #1 0x00007ffff686348c in ffi_call_unix64 () at /home/abingham/src/Python-3.2/Modules/_ctypes/libffi/src/x86/unix64.S:75
 #2 0x00007ffff6862bc3 in ffi_call (cif=0x7fffffffde40, fn=, rvalue=, avalue=)
 at /home/abingham/src/Python-3.2/Modules/_ctypes/libffi/src/x86/ffi64.c:485
 #3 0x00007ffff68574ec in _call_function_pointer (pProc=, argtuple=, flags=,
 argtypes=, restype=, checker=) at /home/abingham/src/Python-3.2/Modules/_ctypes/callproc.c:808
 #4 _ctypes_callproc (pProc=, argtuple=, flags=, argtypes=,
 restype=, checker=) at /home/abingham/src/Python-3.2/Modules/_ctypes/callproc.c:1151
 #5 0x00007ffff684f823 in PyCFuncPtr_call (self=0x7ffff7e3a600, inargs=(), kwds=) at /home/abingham/src/Python-3.2/Modules/_ctypes/_ctypes.c:3766
 #6 0x00000000004db737 in PyObject_Call (func=, arg=, kw=)
 at Objects/abstract.c:2149
 #7 0x00000000004658d4 in do_call (f=
 Frame 0x987d20, for file bar.py, line 5, in llama (lib=&#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;), throwflag=) at Python/ceval.c:4095
 #8 call_function (f=
 Frame 0x987d20, for file bar.py, line 5, in llama (lib=&#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;), throwflag=) at Python/ceval.c:3898
 #9 PyEval_EvalFrameEx (f=
 Frame 0x987d20, for file bar.py, line 5, in llama (lib=&#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;), throwflag=) at Python/ceval.c:2673

</pre></p>
<p>In particular, notice that the &#8220;python&#8221; command changes the GDB prompt to &#8220;&#62;&#8221;. This is how you can tell when you&#8217;re in python mode. To exit python mode, you need to use Ctrl-D (on windows this might be Ctrl-Z&#8230;I haven&#8217;t checked.)</p>
<p>This final stack trace shows a Python source level stack trace provided by the extension:</p>
<p><pre class="brush: plain;">
 (gdb) py-bt
 #9 (unable to read python frame information)
 #12 Frame 0x987d20, for file bar.py, line 5, in llama (lib=&#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;)
 print(lib.get_value())
 #15 Frame 0x98a700, for file bar.py, line 9, in baz ()
 llama()
</pre></p>
<p>It&#8217;s important to recognize that this was all done in the same GDB session, at the same break point, etc. What you can see is that the Python-provided extension gives you a very clear picture of the exact state of the Python stack along with the underlying C stack. If you&#8217;ve ever tried debugging C extensions through GDB, you&#8217;ll immediately appreciate the clarity this provides.</p>
<h3>Other extension features</h3>
<p>The CPython GDB extension provides more than just stack traces and frame annotation. You can also use it to navigate the Python stack:</p>
<p><pre class="brush: plain;">
 (gdb) py-up
 #12 Frame 0x987d20, for file bar.py, line 5, in llama (lib=&#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;)
 print(lib.get_value())
 (gdb) py-up
 #15 Frame 0x98a700, for file bar.py, line 9, in baz ()
 llama()
 (gdb) py-down
 #12 Frame 0x987d20, for file bar.py, line 5, in llama (lib=&#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;)
 print(lib.get_value())
</pre></p>
<p>examine locals:</p>
<p><pre class="brush: plain;">
(gdb) py-locals

lib = &#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;
</pre></p>
<p>list source code:</p>
<p><pre class="brush: plain;">
 (gdb) py-list
 1 import ctypes
 2
 3 def llama():
 4 lib = ctypes.cdll.LoadLibrary('libsome_lib.so')
 5 print(lib.get_value())
 6
 7 def baz():
 8 print('baz')
 9 llama()
 10
</pre></p>
<p>and print individual variables:</p>
<p><pre class="brush: plain;">
 (gdb) py-print lib
 local 'lib' = &#60;CDLL(_FuncPtr=, get_value=, _handle=9720816, _name='libsome_lib.so') at remote 0x7ffff6ac53d0&#62;
</pre></p>
<h3>Limitations</h3>
<p>The CPython extension doesn&#8217;t (yet?) offer a complete debugging solution. For example, I haven&#8217;t found any way to set a break point in Python code. Likewise, you can&#8217;t set watches on Python variables. These features may not even be feasible with the GDB architecture. Nevertheless, the extension is a powerful tool for most debugging needs.</p>
<h2>Installation</h2>
<p>To install the CPython GDB extension, you need to do the following:</p>
<ol>
<li>Compile Python from source. This will produce the file &#8220;python-gdb.py&#8221; at the root of the Python source tree.</li>
<li>Tell GDB where to find extension modules.</li>
<li>Put the generated extension from step 1 where GDB can find it.</li>
</ol>
<p>To do step 1, simply compile Python as you normally would. This is covered extensively by Python, so I won&#8217;t go into the details here.</p>
<p>For step 2, you need to pick a place (or places) for GDB extension modules to live. I just created the directory &#8220;~/.gdb&#8221; for this purpose. To tell GDB to look here for extensions, what you really need to do is extend sys.path in GDB&#8217;s embedded Python interpreter. For example, I have this code in my .gdbinit:</p>
<p><pre class="brush: plain;">
 python
 import sys
 sys.path.insert(0, '/home/abingham/.gdb')
 end
</pre></p>
<p>This effectively puts GDB int python mode and then extends sys.path to look in ~/.gdb.</p>
<p>Finally, to activate the extension module &#8211; that is, to make it available in a particular GDB session &#8211; you need to import it. You do that like this:</p>
<p><pre class="brush: plain;">
 (gdb) Python
 &#62;import python3_2_gdb
 &#62;(gdb)
</pre></p>
<p>(Again, remember that you exit python mode and return to the GDB prompt with Ctrl-D.)</p>
<p>Once you do this, all of the extension commands (py-list, py-up, etc.) and the frame annotations are activated.</p>
<h3>When to load the module</h3>
<p>There is one important point to remember with regard to the timing of the extension import. If you attempt to load the extension before the corresponding Python library has been loaded into memory, you will get errors like this:</p>
<p><pre class="brush: plain;">
 (gdb) python
 &#62;import python3_2_gdb
 &#62;Traceback (most recent call last):
 File &#34;&#34;, line 1, in
 File &#34;/home/abingham/.gdb/python3_2_gdb.py&#34;, line 52, in
 _type_size_t = gdb.lookup_type('size_t')
 RuntimeError: No type named size_t.
 Error while executing Python code.
</pre></p>
<p>Because of this, you generally can not import the CPython extension module in your standard .gdbinit. Rather, you need to load it manually when you need it. In practice this is just fine since you will probably have various versions of the extension that you need at different times (see next section.)</p>
<h3>Dealing with multiple Python versions</h3>
<p>It&#8217;s important to remember that different variants of the Python build will generate different extensions. This is because the variants (e.g. debug and non-debug) will, in general, have different C-level structure sizes. As a result, an extension built for debug Python will not work (or may work incorrectly) for release versions of Python. One way to cope with this is simply to name the different versions of the extension differently. For example, the extension for the normal build of Python 3.2 might be &#8220;python3_2_gdb.py&#8221; while the debug version might be &#8220;python3_2_debug_gdb.py&#8221;. It doesn&#8217;t really matter what naming scheme you use, so just find one that maps to your personal taste.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Hello World!]]></title>
<link>http://bahen2175.com/2012/03/24/hello-world/</link>
<pubDate>Sat, 24 Mar 2012 02:04:17 +0000</pubDate>
<dc:creator>saltedcaramel2011</dc:creator>
<guid>http://bahen2175.com/2012/03/24/hello-world/</guid>
<description><![CDATA[Dedicated to Prof. Shu @ University of Toronto Thank you. #include &lt;stdio.h&gt; int main() { prin]]></description>
<content:encoded><![CDATA[<p>Dedicated to Prof. Shu @ University of Toronto <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Thank you.</p>
<p>#include &#60;stdio.h&#62;</p>
<p>int main() {</p>
<p>printf(&#8220;Hello World!&#8221;);</p>
<p>return 1; //always true<br />
}</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Essential C]]></title>
<link>http://mujtobarafidrahman.wordpress.com/2012/03/20/essential-c/</link>
<pubDate>Tue, 20 Mar 2012 12:58:39 +0000</pubDate>
<dc:creator>mujtobarafidrahman</dc:creator>
<guid>http://mujtobarafidrahman.wordpress.com/2012/03/20/essential-c/</guid>
<description><![CDATA[Try this book&#8230;EssentialC]]></description>
<content:encoded><![CDATA[<p>Try this book&#8230;<a href="https://mujtobarafidrahman.files.wordpress.com/2012/03/essentialc.pdf">EssentialC</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C++ Inheritance]]></title>
<link>http://macjedrzejewski.wordpress.com/2012/03/16/c-inheritance/</link>
<pubDate>Fri, 16 Mar 2012 09:58:55 +0000</pubDate>
<dc:creator>MJ</dc:creator>
<guid>http://macjedrzejewski.wordpress.com/2012/03/16/c-inheritance/</guid>
<description><![CDATA[While using OOP (Object Oriented Programming) we have to operate on classes, so we create our own cl]]></description>
<content:encoded><![CDATA[While using OOP (Object Oriented Programming) we have to operate on classes, so we create our own cl]]></content:encoded>
</item>
<item>
<title><![CDATA[Calculating the sum of the difference of two intergers]]></title>
<link>http://rant4u.com/2012/03/15/calculating-the-sum-of-the-difference-of-two-intergers/</link>
<pubDate>Thu, 15 Mar 2012 00:56:00 +0000</pubDate>
<dc:creator>rant4u</dc:creator>
<guid>http://rant4u.com/2012/03/15/calculating-the-sum-of-the-difference-of-two-intergers/</guid>
<description><![CDATA[&nbsp;&nbsp;&nbsp; // Programmer: // Program purpose: Lab_on_For_Loops 3/14/12 #include &lt;iostream]]></description>
<content:encoded><![CDATA[<p>&#160;&#160;&#160; // Programmer: <br />// Program purpose: Lab_on_For_Loops 3/14/12</p>
<p>#include &#60;iostream&#62;<br />#include &#60;string&#62;<br />#include &#60;iomanip&#62;<br />#include &#60;cmath&#62;</p>
<p>using namespace std;</p>
<p>int main()<br />{<br />&#160;&#160; int num1 = 0,&#160;&#160; //assignment for intgers and bool<br />&#160;&#160;&#160;&#160;&#160; num2 = 0, <br />&#160;&#160;&#160;&#160;&#160; result, <br />&#160;&#160;&#160;&#160;&#160; sum = 0,<br />&#160;&#160;&#160;&#160;&#160; number1;<br />&#160;&#160; bool notevil = false;</p>
<p>&#160;&#160; cout &#60;&#60;&#8221;&#160;&#160;&#160;&#160;&#160;&#160; 1.) Get the sum of two numbers&#8221;&#60;&#60;endl; //starting menu<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;&#160;&#160;&#160;&#160;&#160;&#160; 2.) Exit Program&#8221;&#60;&#60;endl;</p>
<p>&#160;&#160;&#160; cout &#60;&#60;&#8221;Enter a number from the menu to select&#8221;; //asking for a selection<br />&#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; cin &#62;&#62; number1;</p>
<p>&#160;&#160;&#160; switch (number1) // switches number one with a number<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160; case 1: notevil = false; // switches number1 to true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160; case 2: notevil = true; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160; }</p>
<p>&#160;&#160; <br />&#160;&#160;&#160; while(notevil == false) // if #1 is selected go into the &#8220;if&#8221; statement<br />&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160; num1 = num2 = sum = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221;Please enter your first number&#8221;&#60;&#60;endl;// ask user for first number<br />&#160;&#160;&#160;&#160;&#160; cin &#62;&#62; num1;<br />&#160;&#160;&#160; <br />&#160;&#160; while(num2 &#60; num1)<br />&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221;Please enter your second number&#8221;&#60;&#60;endl;// ask user for second number<br />&#160;&#160;&#160;&#160;&#160; cin &#62;&#62; num2;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160; }</p>
<p>&#160;&#160; for(result = num2 &#8211; num1; result &#62;= 0; result&#8211;) //declaring result as the difference between 2 numbers<br />&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160; sum += result + num1; // calculations to add the difference of the numbers<br />&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160; cout &#60;&#60; sum &#60;&#60;endl; //displays teh difference of your 2 numbers</p>
<p>&#160;&#160; cout &#60;&#60;&#8221;&#160;&#160;&#160;&#160;&#160;&#160; 1.) Get the sum of two numbers&#8221;&#60;&#60;endl; //starting menu<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;&#160;&#160;&#160;&#160;&#160;&#160; 2.) Exit Program&#8221;&#60;&#60;endl;</p>
<p>&#160;&#160;&#160; cout &#60;&#60;&#8221;Enter a number from the menu to select&#8221;; //asking for a selection<br />&#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; cin &#62;&#62; number1;</p>
<p>&#160;&#160;&#160; switch (number1) // switches number one with a number<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160; case 1: notevil = false; // switches number1 to true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160; case 2: notevil = true; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160; }</p>
<p>&#160; }<br />&#160; <br />&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; <br />&#160;&#160; system(&#8220;pause&#8221;);<br />&#160;&#160; return 0;<br />}</p>
<p>&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;
<div class="blogger-post-footer"><img width='1' height='1' src='' alt='' /></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[While Loops]]></title>
<link>http://rant4u.com/2012/03/13/while-loops/</link>
<pubDate>Tue, 13 Mar 2012 01:19:00 +0000</pubDate>
<dc:creator>rant4u</dc:creator>
<guid>http://rant4u.com/2012/03/13/while-loops/</guid>
<description><![CDATA[#include &lt;iostream&gt; //Programmer Mitchell Meyer#include &lt;string&gt; //using while loops#inc]]></description>
<content:encoded><![CDATA[<p>#include &#60;iostream&#62; //Programmer Mitchell Meyer<br />#include &#60;string&#62; //using while loops<br />#include &#60;cmath&#62; // 3/12/12<br />using namespace std;<br />&#160;int main()<br />&#160;{<br />&#160;&#160;&#160; char ch1, ch2;<br />&#160;&#160;&#160; int number1, num1;<br />&#160;&#160;&#160; string word;<br />&#160;&#160;&#160; bool word2 = false;</p>
<p>&#160;&#160;&#160; cout &#60;&#60;&#8221;1.) Would you like to play with bools?&#8221;&#60;&#60;endl; //starting menu<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;2.) Would you like to exit the program?&#8221;&#60;&#60;endl;</p>
<p>&#160;&#160;&#160; cout &#60;&#60;&#8221;Enter a number from the menu to select&#8221;; //asking for a selection<br />&#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; cin &#62;&#62; number1;</p>
<p>&#160;&#160;&#160; switch (number1) // switches number one with a number<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160; case &#8217;1&#8242;: number1 = 1;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160; case &#8217;2&#8242;: number1 = 2;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; if (number1 == 1) // executes when 1 is selected<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60; &#8220;You have selected to play with bools, here we go!!&#8221;&#60;&#60;endl; //output if 1 is slected<br />&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221;Is it true that you can watch the world turn? (y or N)&#8221;&#60;&#60;endl; <br />&#160;&#160;&#160;&#160;&#160;&#160; cin &#62;&#62; ch2;<br />&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; while(ch2 == &#8216;y&#8217;) //enter the loop when the user beilieves you can watch teh earth turn<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221;I believe that is incorrect try again (y or n)&#8221;&#60;&#60;endl; // give them another shot<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cin &#62;&#62; ch2;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ch2 = toupper(ch2);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; switch (ch2) //swith char to upper n lower<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#8216;Y&#8217;: ch2 = &#8216;y&#8217;; //actually this does nothing<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#8216;N&#8217;: ch2 = &#8216;n&#8217;; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (ch2 == &#8216;n&#8217;) //if they admit they cant watch the earth turn<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60; &#8220;your right congrats&#8221;&#60;&#60;endl; //ends the program when they admit they cant<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; system (&#8220;pause&#8221;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return 0;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60; &#8220;try again please&#8221;&#60;&#60;endl; //asking them to try again<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cin &#62;&#62; ch2;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; if(number1 == 2) //selection from the menu<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221; you can exit the program after you enter the name of this class&#8221;&#60;&#60;endl; //output<br />&#160;&#160;&#160;&#160;&#160;&#160; cin &#62;&#62; word;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; while (word != &#8220;c++&#8221;) //if tehy enter the name of the class correctly<br />&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(word == &#8220;c++&#8221;)<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60; &#8220;you may now exit, cause your soo samrt&#8221;; //they can exit if they get it right<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221;that is not the name of the class&#8230;&#8221;&#60;&#60;endl; // asking for the right answer<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221;lets try it again:)&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cout &#60;&#60;&#8221; you can exit the program after you enter the name of this class&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cin &#62;&#62; word;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; system (&#8220;pause&#8221;);<br />&#160;&#160;&#160; return 0; //end of program<br />&#160;}
<div class="blogger-post-footer"><img width='1' height='1' src='' alt='' /></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[কেন Programming?]]></title>
<link>http://pronayaprosun.wordpress.com/2012/03/13/keno-programming/</link>
<pubDate>Mon, 12 Mar 2012 18:55:42 +0000</pubDate>
<dc:creator>Pronaya Prosun</dc:creator>
<guid>http://pronayaprosun.wordpress.com/2012/03/13/keno-programming/</guid>
<description><![CDATA[আমাকে আজকাল কয়েকটা কথা বার বার শুনতে হচ্ছে – Programming  খুব কঠিন, Programming একটা বিরক্তিকর জিনিস]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><a href="http://pronayaprosun.files.wordpress.com/2012/03/programming-languages-used-in-most-famous-websites.jpg"><img class="wp-image-22 aligncenter" title="Programming-languages" src="http://pronayaprosun.files.wordpress.com/2012/03/programming-languages-used-in-most-famous-websites.jpg?w=499&h=316" alt="" width="499" height="316" /></a></p>
<p>আমাকে আজকাল কয়েকটা কথা বার বার শুনতে হচ্ছে – Programming  খুব কঠিন, Programming একটা বিরক্তিকর জিনিস, প্রোগ্রামিং করার দরকার কি? ইত্যাদি ইত্যাদি।</p>
<p>একটু চিন্তা করুন, দেখবেন Programming  আমাদের জীবনে একটি অপরিহার্য বিষয় হয়ে দাঁড়িয়েছে। আপনার ব্যবহৃত Calculator থেকে শুরু করে Mobile, Television, Motorized Vehicle, Traffic Signal এমনকি আপনার হাত ঘড়িতেও Programming করা হয়েছে। Programming ছাড়া আধুনিক জীবন কল্পনাই করা যায় না।</p>
<p>আপনি যদি Web development  এর দিকে জেতে চান, তাহলে আপনাকে Server side language  (যেমন: PHP, JSP, ASP), Client side language (যেমন: javascript, vbscript ) শিখতে হবে। Software development এর জন্য C++, C#, Java, Visual Besic ইত্যাদির যেকোনোটি দিয়েই আপনি সেটা করতে পারবেন। আরও অনেক Programming language রয়েছে। আপনি চাইলে সেগুলো নিচের link এ গিয়ে দেখতে পারেন।</p>
<p><a href="http://en.wikipedia.org/wiki/List_of_programming_languages">http://en.wikipedia.org/wiki/List_of_programming_languages</a></p>
<p>এখন প্রশ্ন হল, আমি যদি একটি Programming language দিয়েই সব কিছু করতে পারি, তাহলে এতগুলো ল্যাঙ্গুয়েজ কেন? আসলে এক এক কাজের জন্য এক একটি language উপযুক্ত। তাছাড়া, Computer Scientist রা বিভিন্ন সময়, মানুষের কাছে Programming কে আরও বেশি বোধগম্য করার জন্য, কাজকে সহজ করার জন্য বিভিন্ন Programming language এর জন্ম দিয়েছেন।</p>
<p>অনেকে মনে করতে পারেন, এত language শিখব কিভাবে। সত্যি বলতে আপনাকে এত language শিখতে হবে না। আর যদি শিখতেই হয়, সেটা খুব তাড়াতাড়ি শিখতে পারবেন। যেটা করতে হবে, প্রথমে আপনাকে যেকোনো একটি Programming language খুব ভাল ভাবে আয়ত্ত করতে হবে। প্রথম বার শিখতে হয়ত সময় লাগতে পারে। হতাশাও আসতে পারে। চিন্তার কোন কারণ নেই। একবার যখন Programming এর logic গুলো পরিষ্কার হয়ে যাবে, তখন আপনি অন্য যেকোনো Programming language সহজেই শিখতে পারবেন।</p>
<p>আর একটা কথা, আপনাকে শুধু Programming language শিখলেই চলবে না। সেটাকে কিভাবে প্রয়োগ করতে হয় সেটাও জানতে হবে। এর জন্য, আপনি যে platform এর জন্য Programming করবেন সেটা সম্পর্কে জানতে হবে। Advanced Data Structure ও Algorithm ইত্যাদি সম্পর্কে জানতে হবে। যাই হোক, এগুলো আপনি ধীরে ধীরে শিখতে পারবেন।</p>
<p>এই category তে আমি একটি Programming language সম্পর্ক আলোচনা করব। সেটা হল C programming language। আমার বিশ্বাস, আপনি যদি, এই language টা ভাল ভাবে আয়ত্ত করতে পারেন, তাহলে অন্য যেকোনো language সহজেই আয়ত্ত করতে পারবেন।<br />
এখানে একটা কথা, আপনাকে Programming শিখতে হলে যে C দিয়েই শুরু করতে হবে তা নয়, আপনি সরাসরি আপনার প্রয়োজনীয় Programming language টা শিখা শুরু করতে পারেন।</p>
<p>আমার পরের Post এ Programming language কিভাবে কাজ করে, কি কি বিষয় জানতে হবে, কিভাবে শিখতে হবে – এগুলোর উপর আলোচনা করবো।<br />
যারা Programming শিখতে আগ্রহী, তাদের কথা মাথায় রেখে, আমি এই category টি তৈরি করেছি। আশা করি, আমার Post গুলো থেকে তারা উপকৃত হবেন। আমি প্রতি সপ্তাহে কমপক্ষে একটি করে Post দেয়ার চেষ্টা করবো। তাছাড়া অন্য Category তে অন্য post গুলো তো থাকবেই।</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Silverlight AutoComplete box (The real deal!!)]]></title>
<link>http://objectreferncehell.wordpress.com/2012/03/11/silverlight-autocomplete-box-the-real-deal/</link>
<pubDate>Sun, 11 Mar 2012 14:57:00 +0000</pubDate>
<dc:creator>Gregg</dc:creator>
<guid>http://objectreferncehell.wordpress.com/2012/03/11/silverlight-autocomplete-box-the-real-deal/</guid>
<description><![CDATA[Silverlight Introduction So I have spent quite a bit of time with Silverlight and one thing I really]]></description>
<content:encoded><![CDATA[<h4><b>Silverlight Introduction</b></h4>
<p>So I have spent quite a bit of time with Silverlight and one thing I really like about it is that if you don&#8217;t come from a lot of .NET experience, you get a taste of every aspect of the framework. You may not be able to do &#34;everything&#34; WPF or Windows Forms can do, but you get a lot of experience in it all. Th reason for this is although Silverlight is rich and a great patform, it is client side only. NO SERVER END. Web Services are used as the way to communicate with either the web project or any other tool outside of Silverlight (database for example)</p>
<h4><b>Purpose for the Autocomplete boxes??</b></h4>
<p>In my articles I like to explain somewhere a real world explanation of what a particular tool would be used for. In this case, the Autocomplete tool is most often used in two scenarios</p>
<p>The first use case is when your application has a fixed set of things you wish to have the user choose from and don&#8217;t wish to use a dropdown either because you have too many options for a user to sift through or your users really like the keyboard and want to utilize it to be more efficient. Using AutoComplete boxes allows you to do just that by popping up data values based on what you type in the box (such as looking up someone&#8217;s name). </p>
<p>The second use case for using a AutoComplete box (remember I&#8217;m sure there are tons more, these are just 2 common ones) is for search engines. Notice how Google has had for a long time now, the ability to autocomplete your question before you finish? In it&#8217;s simplest form, this is an autocomplete box that uses a list of words and phrases to match what you are typing on the fly. This is possible using AJAX web methods.</p>
<h4><b>AJAX ( Asynchronous JavaScript and XML)</b></h4>
<p>There is a very special group of web methods called AJAX which allow for a better user experience by making asynchronous calls to the server and instead of the browser waiting for a response from the server before allowing the user to continue interacting with it, the browser continues on it&#8217;s merry way with the user until it gets a returned CallBack from the Event that was originally created. I will go into AJAX more in future blogs, but it has definitely matured quite a but since the late 90&#8242;s.</p>
<h4><b>No more Background.. Lets get the show on the Road</b></h4>
<p>So now that you have some background in what AutoComplete boxes are, what AJAX is, what limits Silverlight etc&#8230; Lets get coding. So first lets create a simple person class in the Silverlight Application. If you want to separate concerns, you can easily do this by placing it in an Entities folder. The Person class should look similar to this:</p>
<p><code>public</code> <code>class</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>public</code> <code>string</code> <code>FirstName { </code><code>get</code><code>; </code><code>set</code><code>; } </code></p>
<p><code></code><code>public</code> <code>string</code> <code>LastName { </code><code>get</code><code>; </code><code>set</code><code>; } </code></p>
<p><code></code><code>public</code> <code>string</code> <code>Department { </code><code>get</code><code>; </code><code>set</code><code>; } </code></p>
<p><code></code></p>
<p><code></code><code>public</code> <code>override</code> <code>string</code> <code>ToString() </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>return</code> <code>FirstName; </code></p>
<p><code></code><code>} </code></p>
<p><code></code><code>} </code></p>
<p><code></code></p>
<p><code>}</code></p>
<p>Overriding the ToString method allows you to instead of getting the object type, get the First name popup in the autocomplete control</p>
<p>Now lets build ourselves a little repository database (really just a list)</p>
<p><code>public</code> <code>class</code> <code>PersonRepository </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>Person _person = </code><code>new</code> <code>Person(); </code></p>
<p><code></code></p>
<p><code></code><code>#region DUMMY DATABASE </code></p>
<p><code></code><code>public</code> <code>List&#60;Person&#62; GetPersonList() </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>List&#60;Person&#62; personList = </code><code>new</code> <code>List&#60;Person&#62;(); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Joe&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Shmo&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;IT&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Gregg&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Tyler&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Software Engineer&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Gary&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Style&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Accounting&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Geoff&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Style&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Accounting&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Michael&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Style&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Accounting&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Matthew&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Style&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Accounting&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Mark&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Style&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Accounting&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Rebeccca&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Smith&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Human Resources&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Richard&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Style&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Accounting&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>personList.Add(</code><code>new</code> <code>Person </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>FirstName = </code><code>&#34;Robert&#34;</code><code>, </code></p>
<p><code></code><code>LastName = </code><code>&#34;Style&#34;</code><code>, </code></p>
<p><code></code><code>Department = </code><code>&#34;Accounting&#34;</code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>return</code> <code>personList; </code></p>
<p><code></code><code>} </code></p>
<p><code></code><code>#endregion </code></p>
<p><code></code><code>}</code></p>
<p>Now lets go into the MainPage.xaml file and add a AutoComplete Box from the ToolBox. This will add the proper references and should create a sdk tag type via this line of code at the top of the screen under the UserControl tag sdk=&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk&#34;. The below code does several things, first, I create two Stack Panels that encapsulate the AutoComplete box as well as the textbox that will populate with the selected Item.</p>
<p><code>&#60;StackPanel Background=</code><code>&#34;LightGray&#34;</code><code>&#62;</code></p>
<p><code></code></p>
<p><code></code></p>
<p><code></code><code>&#60;StackPanel x:Name=</code><code>&#34;AutoRoot&#34;</code> <code>Orientation=</code><code>&#34;Horizontal&#34;</code><code>&#62;</code></p>
<p><code></code></p>
<p><code></code></p>
<p><code></code><code>&#60;sdk:AutoCompleteBox x:Name=</code><code>&#34;AutoBox&#34;</code> <code>Width=</code><code>&#34;200&#34;</code><code>&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;sdk:AutoCompleteBox.ItemTemplate&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;DataTemplate&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;StackPanel&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;TextBlock Text=</code><code>&#34;{Binding Path=FirstName}&#34;</code><code>/&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;/StackPanel&#62;</code></p>
<p><code></code></p>
<p><code></code></p>
<p><code></code><code>&#60;/DataTemplate&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;/sdk:AutoCompleteBox.ItemTemplate&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;/sdk:AutoCompleteBox&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;/StackPanel&#62;</code></p>
<p><code></code></p>
<p><code></code><code>&#60;/StackPanel&#62;</code></p>
<p>You will notice that the TextBlock that corresponds to the AutocompleteBox has it&#8217;s Text property being bound to the FirstName of the Person object. This is important because we are going to do our auto completion based on first name. This is all encapsulated in what is known as a Datatemplate.</p>
<p>The final part is the code behind for the MainPage.</p>
<p><code>public</code> <code>partial</code> <code>class</code> <code>MainPage : UserControl </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>public</code> <code>MainPage() </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>InitializeComponent(); </code></p>
<p><code></code><code>// Create repository and get DB list </code></p>
<p><code></code><code>PersonRepository personRepository = </code><code>new</code> <code>PersonRepository(); </code></p>
<p><code></code><code>List&#60;PERSON&#62; personList = personRepository.GetPersonList(); </code></p>
<p><code></code><code>// Bind list to AutoComplete box </code></p>
<p><code></code><code>this</code><code>.AutoBox.ItemsSource = personList; </code></p>
<p><code></code><code>#region Set Filters for Autocomplete Direct Reports </code></p>
<p><code></code><code>this</code><code>.AutoBox.ItemFilter = ((search, item) =&#62; </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>Person person = item </code><code>as</code> <code>Person; </code></p>
<p><code></code><code>if</code> <code>(personList.Count() != 0) </code></p>
<p><code></code><code>{ </code></p>
<p><code></code><code>string</code> <code>filter = search; </code></p>
<p><code></code><code>return</code> <code>(person.FirstName.Contains(filter)); </code></p>
<p><code></code><code>} </code></p>
<p><code></code><code>return</code> <code>false</code><code>; </code></p>
<p><code></code><code>}); </code></p>
<p><code></code><code>} </code></p>
<p><code></code><code>#endregion </code></p>
<p><code></code><code>}</code></p>
<p>The first part accesses the repository and gets the list from our database and binds it to the AutoComplete controls ItemSource. Then using the AutoCompletes ItemFilter property and lambda expression, You are able to filter inside the list by using the Contains property in the string object as shown below.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[MVC &ndash; The dreaded  &quot;Multiple types were found that match the controller named&quot;]]></title>
<link>http://objectreferncehell.wordpress.com/2012/03/11/mvc-the-dreaded-multiple-types-were-found-that-match-the-controller-named/</link>
<pubDate>Sun, 11 Mar 2012 14:33:00 +0000</pubDate>
<dc:creator>Gregg</dc:creator>
<guid>http://objectreferncehell.wordpress.com/2012/03/11/mvc-the-dreaded-multiple-types-were-found-that-match-the-controller-named/</guid>
<description><![CDATA[&#160; So I have spent time on a project involving MVC and have this dreaded issue that many users s]]></description>
<content:encoded><![CDATA[<p>&#160;</p>
<p>So I have spent time on a project involving MVC and have this dreaded issue that many users seem to have with the routing once you change any of the defaults (for instance areas and namespaces). The error is <strong>&#34;Multiple types were found that match the controller named&#34;</strong></p>
<p>After a lot of banging my head against the wall, crying and almost throwing my laptop out the window, i came across a web site by &#60;a href =&#34;<a href="http://www.johnplummer.com/code/mvc-multiple-types-were-found-that-match-the-controller-named-home.html/comment-page-1#comment-33365&#34;">http://www.johnplummer.com/code/mvc-multiple-types-were-found-that-match-the-controller-named-home.html/comment-page-1#comment-33365&#34;</a>&#62;John Plummer&#60;/a&#62; which mentioned that VS likes to keep your original executable     <br />from when you first created the project and instead of renaming the executable, it just creates another one. This is one of the usual major issues that this error can created.     </p>
<p>Another issue that can cause this is the changing of namespaces and adding areas. If you add the new string to the end of your area registration page like below, it will route your area&#8217;s to the correct controllers:</p>
<p>new { action = &#34;Index&#34;, id = UrlParameter.Optional }, new string[] { &#34;CISE.UserInterface.Controllers&#34;}</p>
<p>Hope this helps others!!   </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C++ Making a Menu]]></title>
<link>http://rant4u.com/2012/03/10/c-making-a-menu/</link>
<pubDate>Sat, 10 Mar 2012 20:57:00 +0000</pubDate>
<dc:creator>rant4u</dc:creator>
<guid>http://rant4u.com/2012/03/10/c-making-a-menu/</guid>
<description><![CDATA[#include &lt;iostream&gt; //Programmer: N/A#include &lt;string&gt; //MidTerm Assignment 3/10/12#incl]]></description>
<content:encoded><![CDATA[<p>#include &#60;iostream&#62; //Programmer: N/A<br />#include &#60;string&#62; //MidTerm Assignment 3/10/12<br />#include &#60;iomanip&#62;<br />#include &#60;cmath&#62;<br />using namespace std;</p>
<p>int main()<br />{<br />&#160;&#160;&#160; double radius, area, length1, length2, base, height; //declares variables throughout the program<br />&#160;&#160;&#160; float num1, num2, num1result1, num2result2;<br />&#160;&#160;&#160; string verb, place, action, descrip, circle, square, triangle;<br />&#160;&#160;&#160; string word1result1, word2result2;<br />&#160;&#160;&#160; char chX;<br />&#160;&#160;&#160; string object1, word1, word2;<br />&#160;&#160;&#160; <br />&#160;&#160;&#160; cout &#60;&#60;&#8221;***************************************&#8221;&#60;&#60; endl; // this is the menu<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*\tPlease select an option&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 1: Calculate area of a shape&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 2: Do a small mad lib&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 3: Swap some variables&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 4: Exit program&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;&#160;&#160;&#160; What is your choice:&#8221; &#60;&#60;endl;<br />&#160;&#160;&#160; cin &#62;&#62; chX;<br />&#160;&#160;&#160; switch(chX)<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; case&#8217;1&#8242; : chX = &#8217;1&#8242;;// switching the char(chX) with 4 different selections <br />&#160;&#160;&#160; &#160;&#160;&#160; break;<br />&#160;&#160;&#160; &#160;&#160;&#160; case&#8217;2&#8242; : chX = &#8217;2&#8242;;<br />&#160;&#160;&#160; &#160;&#160;&#160; break;<br />&#160;&#160;&#160; &#160;&#160;&#160; case&#8217;3&#8242; : chX = &#8217;3&#8242;;<br />&#160;&#160;&#160; &#160;&#160;&#160; break;<br />&#160;&#160;&#160; &#160;&#160;&#160; case&#8217;4&#8242; : chX = &#8217;4&#8242;;<br />&#160;&#160;&#160; &#160;&#160;&#160; break;<br />&#160;&#160;&#160; &#160;&#160;&#160; default: cout &#60;&#60;&#8221;you gave the wrong input, Run the program again&#8221;&#60;&#60;endl; <br />&#160;&#160;&#160; }<br />&#160;&#160;&#160; system(&#8220;cls&#8221;);<br />&#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; if(chX == &#8217;1&#8242;) //user input &#8220;1&#8243; will run this section<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;enter an object: circle, square, triangle: &#8220;; //selecting an object<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; object1;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; if(object1 == &#8220;circle&#8221;) //will caluclate the area of a circle<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter the radius: &#8220;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; radius;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; area = 3.14 * pow(radius, 2);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout&#160; &#60;&#60; &#8220;The area is: &#8221; &#60;&#60; setprecision(10) &#60;&#60; area &#60;&#60;endl; //setprecision is NOT working<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; if(object1 == &#8220;square&#8221;) //will calcualte the area of a square<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter the length of both sides: &#8220;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; length1 &#62;&#62; length2;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; area = length1 * length2;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout&#160; &#60;&#60; &#8220;The area is: &#8221; &#60;&#60; setprecision(10) &#60;&#60; area &#60;&#60;endl; //I do NOT like setprecision<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; if(object1 == &#8220;triangle&#8221;)//will calculate the area of a triangle<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter the base and the height: &#8220;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; base &#62;&#62; height;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; area = .5 * base * height;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout&#160; &#60;&#60; &#8220;The area is: &#8221; &#60;&#60; setprecision(10) &#60;&#60; area &#60;&#60;endl; //I have tried everything to <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; } // fix this precision error, conculsion = I dont like setprecision and it does not like me<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; else<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;endl; //if the user input something other than the shapes listed will out put this<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;You gave the wrong input. Run the program again&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; &#8220;Press enter to exit.&#8221;; //custom exit of the program<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.ignore();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.get();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; return 0;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; if(chX == &#8217;2&#8242;) //if # 2 is selected do the following lines of code<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter a verb: &#8220;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; verb; //user input a verb<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter a place: &#8220;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; place; //user input a place<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter an action : &#8220;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; action; //user input an action<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter a description : &#8220;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; descrip; // user input a description<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;This &#8221; &#60;&#60; verb &#60;&#60; &#8221; test at &#8221; &#60;&#60; place &#60;&#60; &#8221; is too &#8221; &#60;&#60; descrip &#60;&#60;&#8221;!&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;It can go &#8221; &#60;&#60; action &#60;&#60; &#8221; off a cliff!&#8221;&#60;&#60;endl; //combines users inputs<br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; &#8220;Press enter to exit.&#8221;; //custom exit of the program<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.ignore();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.get();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; return 0;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; if(chX == &#8217;3&#8242;) //when #3 is selected the following lines of code will run<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Enter a number, two words ad another number&#8221;&#60;&#60;endl; //asking for input<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin &#62;&#62; num1 &#62;&#62; word1 &#62;&#62; word2 &#62;&#62; num2; //the actual input part<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Word one is: &#8221; &#60;&#60; word1 &#60;&#60;endl; //telling the user what they just typed<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Word two is: &#8221; &#60;&#60; word2 &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Number one is: &#8221; &#60;&#60;num1 &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Number two is: &#8221; &#60;&#60;num2 &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;switching!!!&#8221;&#60;&#60;endl; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; word1result1 = word1; //swaps inputs around<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; word2result2 = word2;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; num2result2 = num2;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; num1result1 =num1;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;word one is now: &#8221; &#60;&#60; word2result2 &#60;&#60;endl; //displays the swap for the user<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;word two is now: &#8221; &#60;&#60; word1result1 &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;number one is now: &#8221; &#60;&#60; num2result2 &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60;&#8221;Number two is now: &#8221; &#60;&#60; num1result1 &#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; &#8220;Press enter to exit.&#8221;; //custom exit of the program<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.ignore();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.get();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; return 0;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; if(chX == &#8217;4&#8242;) // the following lines of code will run if #4 is selected<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; &#8220;Press enter to exit.&#8221;; //custom exit of the program<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.ignore();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cin.get();<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; return 0;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; else(chX &#62; 4);//if any number greater than 4 is enter this will outout<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; cout &#60;&#60; &#8220;you gave the wrong input, Run the program again&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; system (&#8220;pause&#8221;);<br />&#160;&#160;&#160; return 0;<br />}
<div class="blogger-post-footer"><img width='1' height='1' src='' alt='' /></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Lambda Expression (X#X)]]></title>
<link>http://scienceasm.wordpress.com/2012/03/10/lambda-expresions/</link>
<pubDate>Sat, 10 Mar 2012 15:25:06 +0000</pubDate>
<dc:creator>scienceasm</dc:creator>
<guid>http://scienceasm.wordpress.com/2012/03/10/lambda-expresions/</guid>
<description><![CDATA[                                                 ლამბდა გამოსახულებები 1) ლამბდა გამოსახულებები რის ]]></description>
<content:encoded><![CDATA[<p><em><strong>                                                 ლამბდა გამოსახულებები</strong></em><br />
1)<br />
ლამბდა გამოსახულებები რის ანონიმური ფუნქციები ად მეტწილად გამოიყენება დელეგატების შექმნისთვის LINQ-ის გამოყენებით.<br />
ლამბდა გამოსახულება არის უბრალოთ მეთოდი დეკლარირების გარეშე (მაგალითად: წვდომის მოდიფიკატორი, დასაბრუნებელი ტიპი და სახელი)<br />
2)<br />
ძირითადი მიზეზი ლამბდა მეთოდის გამოყენების არის რომ, მოხერხებულია და უბრალოთ მარილია სინტაქსისთვის. საშუალებას გაძლევს რომ დაწერო მეთოდი იმავე ადგილას სადაც გინდა რომ გამოიყენო.<br />
იმ შემთხვევაში როდესაც გაქვს მეთოდი რომელიც ერთხელ არის გამოყენებული ად ასევე პატარა ზომისაა, ლამდა გამოსახულებით შეგიძლია იგივე მეთოდი მატივათ გამოსახო იმავე ადგილას. უპირატესობები შემდაგია:<br />
1. ამცირებს კოდის ზომას ფუნქციის დეკლარების ხარჯზე.<br />
2. კოდი უფრო ცხადი და გარჩევადი ხდება, რადგან არ გიწევს სხვა ადგილას მეთოდის ნახვა და გაჩევა თუ რას აკეთებს მოცემული მეთოდი.</p>
<p>ლამბდა ძირითადათ გამოისახება შემდეგნაირათ<br />
პარამეტრები =&#62; შესასრულებელი კოდი მაგ.<br />
p =&#62; p % 2 == 1<br />
p არის შემავალი პარამეტრი<br />
p % 2 == 1 არის გამოსახულება<br />
p =&#62; p % 2 == 1 წაიკითხება ასე: &#8220;შემავალი პარამეტრი p მიდის ანონიმურ ფუნქციაში რომელისც აბრუნებს true-ს თუ შემავალი მნიშვნელობა არის კენტი&#8221;</p>
<p>მოვიყვანოთ მაგალითი<br />
List&#60;int&#62; numbers = new List&#60;int&#62; { 12, 35, 66, 57 };<br />
List&#60;int&#62; oddNumbers = numbers.Where(n =&#62; n % 2 == 1).ToList();<br />
//oddNumbers შეიცავს 11 და 37</p>
<p>&#8212;-&#62; <a href="http://www.dotnetperls.com/lambda" target="_blank">link </a>&#60;&#8212;&#8211;</p>
<p>&#8212;-&#62; <a href="http://msdn.microsoft.com/en-us/library/bb397687.aspx" target="_blank">link </a>&#60;&#8212;&#8211;</p>
<p>&#8212;-&#62; <a href="http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C" target="_blank">link </a>&#60;&#8212;&#8211;</p>
<p>&#8212;-&#62; <a href="http://www.codeproject.com/Articles/17575/Lambda-Expressions-and-Expression-Trees-An-Introdu" target="_blank">link </a>&#60;&#8212;&#8211;</p>
<p>&#8212;-&#62; <a href="http://msdn.microsoft.com/en-us/library/bb397675.aspx" target="_blank">link </a>&#60;&#8212;&#8211;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C++ MidTerm first page]]></title>
<link>http://rant4u.com/2012/03/09/c-midterm-first-page/</link>
<pubDate>Fri, 09 Mar 2012 23:53:00 +0000</pubDate>
<dc:creator>rant4u</dc:creator>
<guid>http://rant4u.com/2012/03/09/c-midterm-first-page/</guid>
<description><![CDATA[#include &lt;iostream&gt;#include &lt;string&gt;#include &lt;iomanip&gt;#include &lt;cmath&gt;using ]]></description>
<content:encoded><![CDATA[<p>#include &#60;iostream&#62;<br />#include &#60;string&#62;<br />#include &#60;iomanip&#62;<br />#include &#60;cmath&#62;<br />using namespace std;</p>
<p>int main()<br />{<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;***************************************&#8221;&#60;&#60; endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*\tPlease select an option&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 1: Calculate area of a shape&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 2: Do a small mad lib&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 3: Swap some variables&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160; 4: Exit program&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;*&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#8221;&#60;&#60;endl;<br />&#160;&#160;&#160; cout &#60;&#60;&#8221;&#160;&#160;&#160; What is your choice:&#8221; &#60;&#60;endl;</p>
<p>&#160;&#160;&#160; system (&#8220;pause&#8221;);<br />&#160;&#160;&#160; return 0;<br />}
<div class="blogger-post-footer"><img width='1' height='1' src='' alt='' /></div>
]]></content:encoded>
</item>

</channel>
</rss>

