<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-8264121216529648346</atom:id><lastBuildDate>Fri, 22 May 2026 21:00:16 +0000</lastBuildDate><category>Programming</category><category>C Programming</category><category>Computer Tips</category><category>Computers</category><category>Java</category><category>MIPS</category><category>Internet</category><category>Linux</category><category>VHDL</category><category>Διάφορα</category><category>Hardware</category><category>JavaScript</category><category>Ανέκδοτα</category><title>Another Computers Blog</title><description>JAVA and C programming examples and advices. Tips about computing. Also few MIPS examples and advices about assembly.</description><link>http://akomaenablog.blogspot.com/</link><managingEditor>noreply@blogger.com (Andreas Papadopoulos)</managingEditor><generator>Blogger</generator><openSearch:totalResults>66</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><itunes:explicit>no</itunes:explicit><copyright>http://akomaenablog.blogspot.com (R)</copyright><itunes:image href="http://paperunits.googlepages.com/tell_your_opinion.png"/><itunes:keywords>programming,C,programming,Java,programming,assembly,MIPS</itunes:keywords><itunes:summary>JAVA and C programming examples and advices. Tips about computing. Jokes and poems in Greek. Also few MIPS examples and advices about assembly.</itunes:summary><itunes:subtitle>Another Blog</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Software How-To"/></itunes:category><itunes:author>akoma1blog@yahoo.com</itunes:author><itunes:owner><itunes:email>akoma1blog@yahoo.com</itunes:email><itunes:name>akoma1blog@yahoo.com</itunes:name></itunes:owner><xhtml:meta content="noindex" name="robots" xmlns:xhtml="http://www.w3.org/1999/xhtml"/><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-1516082426497956412</guid><pubDate>Fri, 16 Sep 2011 09:27:00 +0000</pubDate><atom:updated>2011-09-16T12:34:28.145+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Hardware</category><title>How mechanical mouse works?</title><description>Mouse allows quick and easy access to many icons and operations on the  computer, such as selecting from a list of possible actions (menu), work  with Windows and moving files. when you move the mouse, the rubber ball  turns and runs two rollers, both associated with wheel with slots.  light-emitting diode (LED) sends light through the slits and transducers  convert light into an electrical signal. Pressing the button will send  additional information to the computer.&lt;br /&gt;The main goal of any mouse is to translate the motion of your hand into signals that the computer can use. Let's take a look inside a track-ball mouse:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUN89VjomMtC4Su0TfBfHJmRjAoBKdSifdPce_vvM_af44T5a6Gy64etpt-vmUVMUoe1G_AyWUxmjh7vF8lTw6ozRLHQ8gv9cnFmnvhD2vLuKgyKfGcM4yRiMDs91lN41c8lsh1eoIRas/s1600/mouse640450.jpg" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUN89VjomMtC4Su0TfBfHJmRjAoBKdSifdPce_vvM_af44T5a6Gy64etpt-vmUVMUoe1G_AyWUxmjh7vF8lTw6ozRLHQ8gv9cnFmnvhD2vLuKgyKfGcM4yRiMDs91lN41c8lsh1eoIRas/s320/mouse640450.jpg" border="0" height="240" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;1. Roller - Roller turns by turning the rubber ball back and forth&lt;br /&gt;2. Rubber Ball - The ball is turning when you run the mouse over the surface&lt;br /&gt;3. Moving Roller&lt;br /&gt;4. Slotted wheel - This wheel with the slots associated with vertical rollers.&lt;br /&gt;5. Light emitting diode&lt;br /&gt;6. Converter&lt;br /&gt;7. Cable coupling&lt;br /&gt;8. Plastic housing&lt;br /&gt;9. Cable - cable connects the mouse to the computer through input on your computer&lt;br /&gt;10. Chip - The chip processes data from the transducer movement and buttons before it transmits them to computer&lt;br /&gt;11. Right button - The button pressing their work to encourage the chip and the chip sends signals to the computer&lt;br /&gt;12. Roller - This is moved by rotation of Roller balls&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjeLxZUnpZdCRLRv-z_4PfkK02sTRZu9IOrm35hVJdrECHNw8G_0IvQrHmwiZ_Fh4QB7StMtTtVkK5oHs-com1CyDskJMJ8HP6hx6HMjlQ11XmQzC0x6lWpQeZnk6U_zL4RXC4DOsbJCU/s1600/mousewheel640.jpg" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjeLxZUnpZdCRLRv-z_4PfkK02sTRZu9IOrm35hVJdrECHNw8G_0IvQrHmwiZ_Fh4QB7StMtTtVkK5oHs-com1CyDskJMJ8HP6hx6HMjlQ11XmQzC0x6lWpQeZnk6U_zL4RXC4DOsbJCU/s320/mousewheel640.jpg" border="0" height="320" width="314" /&gt;&lt;/a&gt;&lt;/div&gt;1. Wheel with slots - when the wheel rotates, the movement of the slot next to the diode produces light flashes&lt;br /&gt;2. Light-emitting diode (LED) - LED sends light through the slits on the outer edge of the wheel&lt;br /&gt;3. Converter - Converter code flashes of light into electrical signals.&lt;br /&gt;4. Roller Lever - Lever roller transfers spins on the wheel with slits.&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://how-computers-work.blogspot.com/" target="blank" rel="nofollow"&gt;http://how-computers-work.blogspot.com&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2011/09/how-mechanical-mouse-works.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUN89VjomMtC4Su0TfBfHJmRjAoBKdSifdPce_vvM_af44T5a6Gy64etpt-vmUVMUoe1G_AyWUxmjh7vF8lTw6ozRLHQ8gv9cnFmnvhD2vLuKgyKfGcM4yRiMDs91lN41c8lsh1eoIRas/s72-c/mouse640450.jpg" width="72"/><thr:total>21</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-3455087095552833942</guid><pubDate>Tue, 23 Feb 2010 10:08:00 +0000</pubDate><atom:updated>2010-02-23T12:10:19.949+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C Programming</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>C example on how to use command line arguments</title><description>In this simple example we will see how to use the &lt;span style="font-weight:bold;"&gt;command line arguments&lt;/span&gt; in our C programs.&lt;br /&gt;Well, we all noticed that main() get two parameters.&lt;br /&gt;int main(int argc, char *argv[]);&lt;br /&gt;argc is an integer representing the size of argv[]&lt;br /&gt;argv is a table of pointer to chars ( Strings )&lt;br /&gt;Below is a simple calculator which takes as arguments two numbers and prints the sum.&lt;br /&gt;The code is:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt;    if ( argc != 3) {&lt;br /&gt;         printf("Usage:\n %s Integer1 Integer2\n",argv[0]);&lt;br /&gt;    } &lt;br /&gt;    else {&lt;br /&gt;         printf("%s + %s = %d\n",argv[1],argv[2], atoi(argv[1])+atoi(argv[2]));&lt;br /&gt;    }&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now lets explain the code:&lt;br /&gt;line 4 : we check if the user passed two arguments to the program. We actually need two arguments but in C the first argument ( argv[0] ) is the name of our program, so we need two more.&lt;br /&gt;line 5 : If the user didn't pass two arguments we print the usage of our program and exit&lt;br /&gt;line 8 : Using atoi() function we convert pointers to char (string) to decimal numbers and display their sum&lt;br /&gt;&lt;br /&gt;Example without arguments&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;C:\&gt;ArgumentCalculator.exe&lt;br /&gt;Usage:&lt;br /&gt; ArgumentCalculator.exe Integer1 Integer2&lt;br /&gt;&lt;br /&gt;C:\&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Example with two arguments&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;C:\&gt;ArgumentCalculator.exe 123456789 987654322&lt;br /&gt;123456789 + 987654322 = 1111111111&lt;br /&gt;&lt;br /&gt;C:\&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In addition to the above the code to print all the arguments is:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt; for(int i = 0 ; i&amp;lt;argc ; i++)&lt;br /&gt;  printf("\nArgument %d: %s", i, argv[i]);&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2010/02/c-example-on-how-to-use-command-line.html</link><thr:total>11</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-2266157084640155479</guid><pubDate>Tue, 23 Feb 2010 09:16:00 +0000</pubDate><atom:updated>2010-02-23T11:43:05.653+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Internet</category><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><title>How to view passwords behind asterisks ****</title><description>Did you saved your password for a site and you forgot it but you can see only ***?&lt;br /&gt;Fortunately is very easy to see your password. How?&lt;br /&gt;&lt;br /&gt;Step1: Copy the following JavaScript code.&lt;br /&gt;Step2: Open the site in a new browser window.&lt;br /&gt;Step3: When you see the asterisks **** appear then paste the code in the address bar and hit enter.&lt;br /&gt;&lt;br /&gt;Voila. You should now see your forgotten password.&lt;br /&gt;Javascript code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;javascript: var p=r(); function r(){var g=0;var x=false;var x=z(document.forms);g=g+1;var w=window.frames;for(var k=0;k&amp;lt;w.length;k++) {var x = ((x) || (z(w[k].document.forms)));g=g+1;}if (!x) alert('Password not found in ' + g + ' forms');}function z(f){var b=false;for(var i=0;i&amp;lt;f.length;i++) {var e=f[i].elements;for(var j=0;j&amp;lt;e.length;j++) {if (h(e[j])) {b=true}}}return b;}function h(ej){var s='';if (ej.type=='password'){s=ej.value;if (s!=''){prompt('Password found ', s)}else{alert('Password is blank')}return true;}}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Javascript code with line numbers&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;javascript:&lt;br /&gt;var p=r(); &lt;br /&gt;function r(){&lt;br /&gt; var g=0;&lt;br /&gt; var x=false;&lt;br /&gt; var x=z(document.forms);&lt;br /&gt; g=g+1;&lt;br /&gt; var w=window.frames;&lt;br /&gt; for(var k=0;k&amp;lt;w.length;k++) {&lt;br /&gt;  var x = ((x) || (z(w[k].document.forms)));&lt;br /&gt;  g=g+1;&lt;br /&gt; }&lt;br /&gt; if (!x) alert('Password not found in ' + g + ' forms');&lt;br /&gt;}&lt;br /&gt;function z(f){&lt;br /&gt; var b=false;&lt;br /&gt; for(var i=0;i&amp;lt;f.length;i++) {&lt;br /&gt;  var e=f[i].elements;&lt;br /&gt;  for(var j=0;j&amp;lt;e.length;j++) {&lt;br /&gt;   if (h(e[j])) {&lt;br /&gt;    b=true&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; return b;&lt;br /&gt;}&lt;br /&gt;function h(ej){&lt;br /&gt; var s='';&lt;br /&gt; if (ej.type=='password'){&lt;br /&gt;  s=ej.value;&lt;br /&gt;  if (s!=''){&lt;br /&gt;   prompt('Password found ', s)&lt;br /&gt;  }&lt;br /&gt;  else{&lt;br /&gt;   alert('Password is blank')&lt;br /&gt;  }&lt;br /&gt;  return true;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Here are some screens to see how it works.&lt;br /&gt;I used the &lt;a href="http://www.facebook.com/login.php" rel="no follow" target="new"&gt;facebook log in page&lt;/a&gt; for the example.&lt;br /&gt;Step1:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqZRgRVKacOCugmdjKS583o63MRMrC4RHaMUuyg-FbMDFzb6e_uxJ_ZxNF0yup9R6fhCtAMzlsD0vFHPA0yxPKjHtaBFkPdgI-Pe5dVJak8tjq9oiEq59A2cy7XvDsBXoK39jkedil1A/s1600-h/asteriskPasswords1.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 296px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqZRgRVKacOCugmdjKS583o63MRMrC4RHaMUuyg-FbMDFzb6e_uxJ_ZxNF0yup9R6fhCtAMzlsD0vFHPA0yxPKjHtaBFkPdgI-Pe5dVJak8tjq9oiEq59A2cy7XvDsBXoK39jkedil1A/s400/asteriskPasswords1.jpg" alt="" id="BLOGGER_PHOTO_ID_5441369164608809138" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Step2 and Step3&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1wzj6T8bI75DFokTFvxPKzZp4I_ON_7YH6ispXH5pOvhIlqX-i6W_AlxCVjAhVNKLe4-156j1egli2030pWrC_chwilg2eExAf2d4YDyp-EQxuF0-St_O_x2XQtcvc3YfkovDGcAmhg/s1600-h/asteriskPasswords2.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 296px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1wzj6T8bI75DFokTFvxPKzZp4I_ON_7YH6ispXH5pOvhIlqX-i6W_AlxCVjAhVNKLe4-156j1egli2030pWrC_chwilg2eExAf2d4YDyp-EQxuF0-St_O_x2XQtcvc3YfkovDGcAmhg/s400/asteriskPasswords2.jpg" alt="" id="BLOGGER_PHOTO_ID_5441369580240002626" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I hope this helped you find you forgotten passwords.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2010/02/how-to-view-passwords-behind-asterisks.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqZRgRVKacOCugmdjKS583o63MRMrC4RHaMUuyg-FbMDFzb6e_uxJ_ZxNF0yup9R6fhCtAMzlsD0vFHPA0yxPKjHtaBFkPdgI-Pe5dVJak8tjq9oiEq59A2cy7XvDsBXoK39jkedil1A/s72-c/asteriskPasswords1.jpg" width="72"/><thr:total>18</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-4151628718630750987</guid><pubDate>Sat, 06 Jun 2009 08:25:00 +0000</pubDate><atom:updated>2009-06-06T11:35:36.594+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Internet</category><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><title>How to create a cool Button for your website</title><description>With this post I will show you how to create a cool button to use in your webpages or anywhere you want for free!&lt;br /&gt;In my I case I wanted to add a download button for the code parts I post here.&lt;br /&gt;&lt;br /&gt;Step1:&lt;br /&gt;Go to &lt;a href="http://cooltext.com/" target="blank"&gt;Cool Text Graphics Generator&lt;/a&gt;&lt;br /&gt;And go down to Choose a Button Design and select the button you like&lt;br /&gt;&lt;br /&gt;Step2:&lt;br /&gt;Write your text and select the disired fonts and colours.&lt;br /&gt;In my case the text was "DOWNLOAD".&lt;br /&gt;Filled the colours and selected Text Offest Y = -5 (move the text 5 pixels up from the center)&lt;br /&gt;For Mouse over I selected Glow.&lt;br /&gt;Now hit the button "Render Button"&lt;br /&gt;Here you see two images. One for the normal button and one for the mouseover trigger.&lt;br /&gt;Just save/download the first image. e.g. mybutton.png&lt;br /&gt;Mine is&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkXgJB9vmQPUU-xJ2MDp1Oo7tKUW94xEFIOvMI23l_iSF6eHAbS-kWzIUULWW8ycVwNNgzu-fMr-RIG8Z3l8cy8RZ4lCZ3SEjmQlX5E26qPfnEv3biNzNPX9eJC3iIj7k87GRQ9p2oaA/s1600-h/dB.png"&gt;&lt;img style="cursor: pointer; width: 119px; height: 39px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkXgJB9vmQPUU-xJ2MDp1Oo7tKUW94xEFIOvMI23l_iSF6eHAbS-kWzIUULWW8ycVwNNgzu-fMr-RIG8Z3l8cy8RZ4lCZ3SEjmQlX5E26qPfnEv3biNzNPX9eJC3iIj7k87GRQ9p2oaA/s320/dB.png" alt="" id="BLOGGER_PHOTO_ID_5344128029114146850" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Step3:&lt;br /&gt;Click "Edit this logo" and change Text Offest Y to 0 and click again "Render Button"&lt;br /&gt;Now save the second image.  e.g. mybuttonMouseOver.png&lt;br /&gt;Mine is&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg881z0tGgyxoFfvOrv3krrHXXt4RlXdjmYRZBrZcp7TBM3ehBscqXKdbPPqcWEfMRwpkvXwq0305JIbo9w8HLFyzqScews_EVBiheUAR2KNNBX6ceCCjDa9sbS6zI9ko0og9aT3mn0aQ/s1600-h/dB_MO.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 119px; height: 39px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg881z0tGgyxoFfvOrv3krrHXXt4RlXdjmYRZBrZcp7TBM3ehBscqXKdbPPqcWEfMRwpkvXwq0305JIbo9w8HLFyzqScews_EVBiheUAR2KNNBX6ceCCjDa9sbS6zI9ko0og9aT3mn0aQ/s400/dB_MO.png" alt="" id="BLOGGER_PHOTO_ID_5344128164970334930" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Step4:&lt;br /&gt;Now we have the two images we need. We just have to upload them somewhere.&lt;br /&gt;There are a lot of &lt;a href="http://dwreanwebhosting.googlepages.com/" target="blank"&gt;free web host and space providers&lt;/a&gt; for your files. Just choose who you like.&lt;br /&gt;Let's say you uploaded the two pictures to the address http://myurl/&lt;br /&gt;&lt;br /&gt;To display the picture you write the following html:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;img src="http://myurl/mybutton.png" border=none&lt;br /&gt;onmouseover="this.src='http://myurl/mybuttonMouseOver.png';"&lt;br /&gt;onmouseout="this.src='http://myurl/mybutton.png';" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Step5:&lt;br /&gt;Wait a minute here... We are not done. We just show the picture without any link...&lt;br /&gt;Fortunately is easy to add link to the above picture. Let's say you want a link to http://mylink&lt;br /&gt;then add before the &amp;lt;img...&lt;br /&gt;&amp;lt;a href="http://akomaenablog.blogspot.com"&amp;gt; and at the end close it by adding &amp;lt;/a&amp;gt;&lt;br /&gt;&lt;br /&gt;That's it! Now you have a cool button linking anywhere you want like my cool Download button!&lt;br /&gt;&lt;br /&gt;&lt;a href="" rel="nofollow"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;&lt;a href="" rel="nofollow"&gt;&lt;img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkXgJB9vmQPUU-xJ2MDp1Oo7tKUW94xEFIOvMI23l_iSF6eHAbS-kWzIUULWW8ycVwNNgzu-fMr-RIG8Z3l8cy8RZ4lCZ3SEjmQlX5E26qPfnEv3biNzNPX9eJC3iIj7k87GRQ9p2oaA/s320/dB.png" alt="This is a test button" onmouseover="this.src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg881z0tGgyxoFfvOrv3krrHXXt4RlXdjmYRZBrZcp7TBM3ehBscqXKdbPPqcWEfMRwpkvXwq0305JIbo9w8HLFyzqScews_EVBiheUAR2KNNBX6ceCCjDa9sbS6zI9ko0og9aT3mn0aQ/s400/dB_MO.png';" onmouseout="this.src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkXgJB9vmQPUU-xJ2MDp1Oo7tKUW94xEFIOvMI23l_iSF6eHAbS-kWzIUULWW8ycVwNNgzu-fMr-RIG8Z3l8cy8RZ4lCZ3SEjmQlX5E26qPfnEv3biNzNPX9eJC3iIj7k87GRQ9p2oaA/s320/dB.png';" border="none" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Tip:&lt;br /&gt;Use alt tag to show some text if picture is not available. e.g.&lt;br /&gt;&amp;lt;img src="http://myurl/mybutton.png" alt="Download The Code" ....&lt;br /&gt;&lt;br /&gt;Thank you for reading my posts. Any comments are appreciated&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2009/06/how-to-create-cool-button-for-your.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkXgJB9vmQPUU-xJ2MDp1Oo7tKUW94xEFIOvMI23l_iSF6eHAbS-kWzIUULWW8ycVwNNgzu-fMr-RIG8Z3l8cy8RZ4lCZ3SEjmQlX5E26qPfnEv3biNzNPX9eJC3iIj7k87GRQ9p2oaA/s72-c/dB.png" width="72"/><thr:total>6</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-3623643641200991945</guid><pubDate>Sat, 30 May 2009 21:53:00 +0000</pubDate><atom:updated>2009-05-31T11:20:01.907+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Internet</category><category domain="http://www.blogger.com/atom/ns#">JavaScript</category><title>How to display source code with line numbers into a Blog</title><description>Today I realized that it will be better to have line numbers shown with the parts of code I publish into this blog.&lt;br /&gt;I tried with google but didn't find any "easy" way to do it.&lt;br /&gt;So I figured out my way which I am going to describe here!&lt;br /&gt;First of all I wanted to show line numbers for the code but I also wanted the visitors to be able to copy the code without the line numbers.&lt;br /&gt;&lt;br /&gt;As I'm using the &amp;lt;pre&amp;gt; tag to show my code I wrote a JavaScript function which will get the pre tags and change their innerHtml.&lt;br /&gt;&lt;br /&gt;Here is the function:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;function showLineNumbers() {&lt;br /&gt; /************************************ &lt;br /&gt; * Written by Andreas Papadopoulos   *&lt;br /&gt; * http://akomaenablog.blogspot.com  *&lt;br /&gt; * akoma1blog@yahoo.com              *&lt;br /&gt; ************************************/&lt;br /&gt;  var isIE = navigator.appName.indexOf(&amp;#39;Microsoft&amp;#39;) != -1;&lt;br /&gt;&lt;br /&gt;  var preElems = document.getElementsByTagName(&amp;#39;pre&amp;#39;);&lt;br /&gt;  if (preElems.length == 0) return;&lt;br /&gt;  for (var i = 0; i &amp;lt; preElems.length; i++) {&lt;br /&gt;    var pre = preElems[i];&lt;br /&gt;    var oldContent = pre.innerHTML;&lt;br /&gt;    oldContent = oldContent.replace(/ /g,&amp;quot;&amp;amp;nbsp;&amp;quot;);&lt;br /&gt;    var strs = oldContent.split(&amp;quot;&amp;lt;br&amp;gt;&amp;quot;);&lt;br /&gt;    if (isIE) {&lt;br /&gt;       strs = oldContent.split(&amp;quot;&amp;lt;BR&amp;gt;&amp;quot;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    oldContent = oldContent.substring(4); //remove the 1st &amp;lt;br&amp;gt;&lt;br /&gt;    var newContent = &amp;quot;&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;quot;;&lt;br /&gt;    newContent  = &amp;quot;&amp;lt;td bgcolor=&amp;#39;#d4d0c8&amp;#39;&amp;gt;&amp;quot;;&lt;br /&gt;    for(var j=1; j &amp;lt; strs.length - 1; j++) {&lt;br /&gt;        newContent += j+&amp;quot;.&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;    }&lt;br /&gt;    newContent += &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;;&lt;br /&gt;    newContent += oldContent;&lt;br /&gt;    newContent += &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt;    pre.innerHTML = newContent;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I saved the above in a file let's say showLineNumbers.js and uploaded somewhere.&lt;br /&gt;Let's explain the code: &lt;br /&gt;Line7: Check if browser is Internet Explorer&lt;br /&gt;Line9: Get all the pre elements&lt;br /&gt;Line13: Get the html inside the pre tag&lt;br /&gt;Line14: Replace all the spaces with the sequence &amp;quot;&amp;amp;nbsp;&amp;quot;&lt;br /&gt;Line14: Remove the first &amp;lt;br&amp;gt; from the inner Html&lt;br /&gt;Line15-18: How many lines are in the pre tag (depending on browser)&lt;br /&gt;Line21-22: Html code to create a table , row and a cell with background colour = #d4d0c8 (You can change it if you don't like it)&lt;br /&gt;Lines23-25: Fill the cell with the numbers 1 till the lines of pre tag&lt;br /&gt;Line26-28: Add the old content in the next cell&lt;br /&gt;Line30: Set the new html code as the code for the tag element&lt;br /&gt;&lt;br /&gt;Notice that you can copy the code without the line numbers if you want. You just copy the right cell of the table! That's something I really wanted. &lt;b&gt;Visitors can copy only the code!&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;After that I had to link the code with my template.&lt;br /&gt;How?&lt;br /&gt;Log in to Blogger - Select Layout and then Edit HTML&lt;br /&gt;Now add before the &amp;lt;/head&amp;gt; the line:&lt;br /&gt;&amp;lt;script src=&amp;#39;http://..../showLineNumbers.js&amp;#39; type=&amp;#39;text/javascript&amp;#39;/&amp;gt;&lt;br /&gt;&lt;br /&gt;and now we have to call the function in the showLineNumbers.js so we add before the &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;script type=&amp;#39;text/javascript&amp;#39;&amp;gt;&lt;br /&gt; showLineNumbers();&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;Preview template and if it's ok save it. Remember to backup your template before changes.&lt;br /&gt;&lt;br /&gt;Tip1:&lt;br /&gt;If you use pre tag for other purposes too or you use other tag you defined in a css file for your code&lt;br /&gt;then edit the javascript function for your needs.&lt;br /&gt;&lt;br /&gt;For example if you defined the tag code in your css file and use it inside a pre block then you add&lt;br /&gt;these lines to the function at line 12:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    var code = pre.getElementsByTagName(&amp;#39;code&amp;#39;)[0];&lt;br /&gt;    if (code == null) continue; // no code; move on&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Tip2:&lt;br /&gt;You can use the tool &lt;a href="http://www.elliotswan.com/postable/" target="_blank"&gt;postable&lt;/a&gt; to replace any characters that create problem with html.&lt;br /&gt;&lt;br /&gt;Tip3:&lt;br /&gt;I tested the above code with &lt;a href="http://akomaenablog.blogspot.com"&gt;Another Computers Blog&lt;/a&gt; and firefox 3.0.10 and Internet Explorer 8 and worked fine.&lt;br /&gt;&lt;br /&gt;I hope this will help you. I am waiting for your comments.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2009/05/how-to-display-source-code-with-line.html</link><thr:total>10</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-3980112860463475496</guid><pubDate>Mon, 25 May 2009 10:17:00 +0000</pubDate><atom:updated>2009-05-30T14:07:33.709+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C Programming</category><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>My First Program in C Programming Language</title><description>Programing in C is not that difficult if you know the basic rules.&lt;br /&gt;&lt;br /&gt;I'll show you how to create a simple program in C.&lt;br /&gt;&lt;br /&gt;First of all open a text editor(kate,kwrite,vi,whatever you want). To compile the file I will show you, you will need to have gcc installed in your pc. If you are on Linux you open the software management,select gcc and install it. If you are on Windows I suggest you use a C developing program like Dev-Cpp witch is free.&lt;br /&gt;&lt;br /&gt;If you installed Dev-Cpp on Windows or gcc on linux just do the following.&lt;br /&gt;&lt;br /&gt;Open Dev-Cpp or a text editor and create a new empty file and save it as myfirstcprogram.c&lt;br /&gt;&lt;br /&gt;Now first you have to include the stdio (standard library for input/output) so write in the first line&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;The next step is to write the header of the main function,open brackets {} and write your code.&lt;br /&gt;&lt;br /&gt;This is your first program and I'm going to explain it.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt;int a,b;&lt;br /&gt;printf(&amp;quot;give number a : &amp;quot;);&lt;br /&gt;scanf(&amp;quot;%d&amp;quot;,&amp;amp;a);&lt;br /&gt;printf(&amp;quot;give number b : &amp;quot;);&lt;br /&gt;scanf(&amp;quot;%d&amp;quot;,&amp;amp;b);&lt;br /&gt;printf(&amp;quot;%d   %d = %d\n&amp;quot;,a,b,a b);&lt;br /&gt;exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now, What does the above code do?&lt;br /&gt;&lt;br /&gt;Line 1: include the stdio library(explained above)&lt;br /&gt;&lt;br /&gt;Line 2: main function from where your program will start execution&lt;br /&gt;&lt;br /&gt;Line 3: we say that we have two integers named a and b&lt;br /&gt;&lt;br /&gt;Line 4: print at the desktop the message give number a&lt;br /&gt;&lt;br /&gt;Line 5: read the number entered. the function scanf waits until enter is pressed&lt;br /&gt;&lt;br /&gt;Line 5 and 6 : do the same as 4 and 5 to read the number b&lt;br /&gt;&lt;br /&gt;Line 7: prints the message number a + number b = a+b&lt;br /&gt;&lt;br /&gt;Line 8: the program ended successfully&lt;br /&gt;&lt;br /&gt;Now that you wrote the above code you have to compile it.&lt;br /&gt;&lt;br /&gt;In Linux in the directory you saved the file type in the Konsole&lt;br /&gt;&lt;br /&gt;gcc myfirstcprogram.c -o myfirstprogram&lt;br /&gt;&lt;br /&gt;in Windows from the Dev-C++ menu select exectute - compile.&lt;br /&gt;&lt;br /&gt;In windows open command prompt windows (start - run -cmd - ok)&lt;br /&gt;&lt;br /&gt;use cd command to go to the directory you saved it.&lt;br /&gt;&lt;br /&gt;In windows type myfirstprogram and press enter&lt;br /&gt;&lt;br /&gt;and in Linux type ./myfirstprogram&lt;br /&gt;&lt;br /&gt;Now you see the message " give number a : " type a number and press enter and you will see the same message for the number b so do the same again.&lt;br /&gt;&lt;br /&gt;After that you will see the result : a + b = sum&lt;br /&gt;&lt;br /&gt;Example of output:&lt;br /&gt;&lt;br /&gt;give number a : 3&lt;br /&gt;&lt;br /&gt;give number b : 4&lt;br /&gt;&lt;br /&gt;3 + 4 = 7&lt;br /&gt;&lt;br /&gt;That's it. You wrote and compiled your first program in C!!!&lt;/stdio.h&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2009/05/my-first-program-in-c-programming.html</link><thr:total>3</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-2259162547068629369</guid><pubDate>Thu, 22 Jan 2009 23:09:00 +0000</pubDate><atom:updated>2009-01-31T21:23:07.984+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MIPS</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>MIPS Reverse a String</title><description>MIPS example to reverse a string.&lt;br /&gt;&lt;br /&gt;First it will be better to show how MIPS stores strings.&lt;br /&gt;&lt;br /&gt;e.g.&lt;br /&gt;the phrase "computerblog"&lt;br /&gt;will be saved (address start form down to up):&lt;br /&gt;&lt;style type="text/css"&gt;.nobrtable br { display: none ; padding:2; spacing:2; border: 3px solid black;}&lt;/style&gt;&lt;br /&gt;&lt;div class="nobrtable"&gt;&lt;br /&gt;&lt;table width="50%" &gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;??&lt;/td&gt;&lt;td&gt;??&lt;/td&gt;&lt;td&gt;??&lt;/td&gt;&lt;td&gt;00(zero byte)&lt;/td&gt;&lt;td&gt;0x...b&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;g = 67&lt;/td&gt;&lt;td&gt;o = 6f&lt;/td&gt;&lt;td&gt;l = 6c&lt;/td&gt;&lt;td&gt;b = 62&lt;/td&gt;&lt;td&gt;0x...8&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;r = 72&lt;/td&gt;&lt;td&gt;e = 65&lt;/td&gt;&lt;td&gt;t = 74&lt;/td&gt;&lt;td&gt;u = 75&lt;/td&gt;&lt;td&gt;0x...4&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;p = 70&lt;/td&gt;&lt;td&gt;m = 6d&lt;/td&gt;&lt;td&gt;o = 6f&lt;/td&gt;&lt;td&gt;c = 63&lt;/td&gt;&lt;td&gt;0x...0&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;0x??????00    0x....b&lt;br /&gt;0x676f6c62    0x....8&lt;br /&gt;0x72657475    0x....4&lt;br /&gt;0x706d6f63    0x....0&lt;br /&gt;&lt;br /&gt;and reversed should be:&lt;br /&gt;0x20736c00    0x....b&lt;br /&gt;0x636f6d70    0x....8&lt;br /&gt;0x75746572    0x....4&lt;br /&gt;0x626c6f67    0x....0&lt;br /&gt;&lt;br /&gt;when making syscall with 4 (li $v0,4) and $a = x00&lt;br /&gt;will start printing bytes (characters) till the ending 0 (a zero byte)&lt;br /&gt;&lt;br /&gt;Now I think it will be easier to understand the following MIPS code.&lt;br /&gt;At this point it would be good to mention that it works only if the string length is even (2,4,6...2*k).&lt;br /&gt;If you want it for odd length strings too you can solve it by changing the strreverse (after exiting loop if odd do another one loop) and please leave your comments.&lt;br /&gt;Anw, this is the code (lines with comment *change means that it affects the table size or the strreverse function):&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;.data&lt;br /&gt;.align 1&lt;br /&gt;String: .space 14 #*change&lt;br /&gt;msg1: .asciiz "Pls give a character: "&lt;br /&gt;msg2: .asciiz "\n"&lt;br /&gt;msg3: .asciiz "String is: "&lt;br /&gt;msg4: .asciiz "\nString Reversed is: "&lt;br /&gt;.text&lt;br /&gt;.globl main&lt;br /&gt;main:&lt;br /&gt;&lt;br /&gt;addi $s0,$zero,13 #*change&lt;br /&gt;addi $t0,$zero,0&lt;br /&gt;&lt;br /&gt;in:&lt;br /&gt;la $a0,msg2&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg1&lt;br /&gt;syscall&lt;br /&gt;li $v0,12&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;add $t1,$v0,$zero&lt;br /&gt;sb $t1,String($t0)&lt;br /&gt;addi $t0,$t0,1&lt;br /&gt;slt $t1,$s0,$t0&lt;br /&gt;beq $t1,$zero,in&lt;br /&gt;&lt;br /&gt;sb $zero,String($t0) #ending zero&lt;br /&gt;&lt;br /&gt;la $a0,msg2&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;la $a0,msg2&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;la $a0,msg3&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;la $a0,String&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;addi $a1,$zero,14 #pass length-*change&lt;br /&gt;jal stringreverse #reverse&lt;br /&gt;&lt;br /&gt;la $a0,msg2&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;la $a0,msg4&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;la $a0,String&lt;br /&gt;li $v0,4&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;li $v0,10&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;stringreverse:&lt;br /&gt;&lt;br /&gt;add $t0,$a0,$zero #beginning address&lt;br /&gt;&lt;br /&gt;add $t1,$zero,$zero  #i=0&lt;br /&gt;addi $t2,$a1,-1   #j=length-1&lt;br /&gt;&lt;br /&gt;loop:&lt;br /&gt;&lt;br /&gt;add $t3,$t0,$t1&lt;br /&gt;lb $t4,0($t3) #lb String[i]&lt;br /&gt;&lt;br /&gt;add $t5,$t0,$t2&lt;br /&gt;lb $t6,0($t5) #lb String[j]&lt;br /&gt;&lt;br /&gt;sb $t4,0($t5) #String[j]=String[i]&lt;br /&gt;sb $t6,0($t3) #String[i]=String[j]&lt;br /&gt;&lt;br /&gt;addi $t1,$t1,1 #i++&lt;br /&gt;addi $t2,$t2,-1 #j--&lt;br /&gt;#if i&amp;gt;=j break - $t1&amp;lt;$t2&lt;br /&gt;slt $t6,$t2,$t1&lt;br /&gt;beqz $t6,loop&lt;br /&gt;&lt;br /&gt;jr $ra&lt;br /&gt;&lt;br /&gt;#i-0;j=length-1;&lt;br /&gt;# do {&lt;br /&gt;# x = str[i]&lt;br /&gt;# str[i]=str[j]&lt;br /&gt;# str[j] = x&lt;br /&gt;# i++;j--;&lt;br /&gt;# } while(!(j&amp;lt;i))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Example of output:&lt;br /&gt;&lt;br /&gt;Pls give a character: c&lt;br /&gt;Pls give a character: o&lt;br /&gt;Pls give a character: m&lt;br /&gt;Pls give a character: p&lt;br /&gt;Pls give a character: u&lt;br /&gt;Pls give a character: t&lt;br /&gt;Pls give a character: e&lt;br /&gt;Pls give a character: r&lt;br /&gt;Pls give a character: s&lt;br /&gt;Pls give a character:&lt;br /&gt;Pls give a character: b&lt;br /&gt;Pls give a character: l&lt;br /&gt;Pls give a character: o&lt;br /&gt;Pls give a character: g&lt;br /&gt;&lt;br /&gt;String is : computers blog&lt;br /&gt;&lt;br /&gt;String Reversed is : golb sretupmoc&lt;br /&gt;&lt;br /&gt;You may also want to see my post about &lt;a href="http://akomaenablog.blogspot.com/2008/05/c-example-to-reverse-file.html"&gt;how to reverse a file in C / C++&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I hope you find this post helpful and please leave your comments. Thank you.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2009/01/mips-reverse-string.html</link><thr:total>6</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-1890018028628536188</guid><pubDate>Thu, 22 Jan 2009 11:10:00 +0000</pubDate><atom:updated>2009-01-22T13:13:12.874+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MIPS</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>MIPS Compare Strings</title><description>This is another MIPS example (program) which:&lt;br /&gt;- ask user to enter two strings (max 20 characters) and saves them into memory.&lt;br /&gt;- call (jal) a function (strcmp) which compares the two string and returns 0 (zero) if the two strings are the same or 1 (one) if not.&lt;br /&gt;- prints a message depending on what strcmp returned.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;.data&lt;br /&gt;msg1:.asciiz "Please insert text (max 20 characters): "&lt;br /&gt;msg2:.asciiz "\nNOT SAME"&lt;br /&gt;msg3:.asciiz "\nSAME"&lt;br /&gt;str1: .space 20&lt;br /&gt;str2: .space 20&lt;br /&gt;.text&lt;br /&gt;.globl main&lt;br /&gt;main:&lt;br /&gt;addi $v0,4&lt;br /&gt;la $a0,msg1&lt;br /&gt;syscall&lt;br /&gt;li $v0,8&lt;br /&gt;la $a0,str1&lt;br /&gt;addi $a1,$zero,20&lt;br /&gt;syscall   #got string 1&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg1&lt;br /&gt;syscall&lt;br /&gt;li $v0,8&lt;br /&gt;la $a0,str2&lt;br /&gt;addi $a1,$zero,20&lt;br /&gt;syscall   #got string 2&lt;br /&gt;&lt;br /&gt;la $a0,str1  #pass address of str1&lt;br /&gt;la $a1,str2  #pass address of str2&lt;br /&gt;jal strcmp  #call strcmp&lt;br /&gt;&lt;br /&gt;beq $v0,$zero,ok #check result&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg2&lt;br /&gt;syscall&lt;br /&gt;j exit&lt;br /&gt;ok:&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg3&lt;br /&gt;syscall&lt;br /&gt;exit:&lt;br /&gt;li $v0,10&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;strcmp:&lt;br /&gt;add $t0,$zero,$zero&lt;br /&gt;add $t1,$zero,$a0&lt;br /&gt;add $t2,$zero,$a1&lt;br /&gt;loop:&lt;br /&gt;lb $t3($t1)  #load a byte from each string&lt;br /&gt;lb $t4($t2)&lt;br /&gt;beqz $t3,checkt2 #str1 end&lt;br /&gt;beqz $t4,missmatch&lt;br /&gt;slt $t5,$t3,$t4  #compare two bytes&lt;br /&gt;bnez $t5,missmatch&lt;br /&gt;addi $t1,$t1,1  #t1 points to the next byte of str1&lt;br /&gt;addi $t2,$t2,1&lt;br /&gt;j loop&lt;br /&gt;&lt;br /&gt;missmatch: &lt;br /&gt;addi $v0,$zero,1&lt;br /&gt;j endfunction&lt;br /&gt;checkt2:&lt;br /&gt;bnez $t4,missmatch&lt;br /&gt;add $v0,$zero,$zero&lt;br /&gt;&lt;br /&gt;endfunction:&lt;br /&gt;jr $ra&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Example of the output:&lt;br /&gt;&lt;br /&gt;Please insert text (max 20 characters): akoma ena blog&lt;br /&gt;Please insert text (max 20 characters): computers blog&lt;br /&gt;NOT SAME&lt;br /&gt;&lt;br /&gt;Please insert text (max 20 characters): computers blog&lt;br /&gt;Please insert text (max 20 characters): computers blog&lt;br /&gt;SAME&lt;br /&gt;&lt;br /&gt;Thank you very much for visiting and reading. I hope this example was helpful to you.&lt;br /&gt;Any comments are appreciated.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2009/01/mips-compare-strings.html</link><thr:total>7</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-5079783951072594763</guid><pubDate>Thu, 22 Jan 2009 10:39:00 +0000</pubDate><atom:updated>2009-01-22T12:58:26.727+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>JMenuItem not visible - JMenuItem behind Canvas</title><description>I was trying to make a GUI in java where I needed to have a JMenuBar (with some JMenuItems) and a Canvas. The problem I run into was that my JMenuItems were shown behind Canvas. I didn't know why so I searched the web to find the solution. I was not very lucky and for a few hours the only important "think" I found was that Canvas is heavyweight component (awt) and JMenuItem is lightweight (swing) component. And you only mix them if you know exactly what you are doing... So I "solved" that by only using awt components. How? It isn't difficult.&lt;br /&gt;Just remove all J :-P&lt;br /&gt;e.g.&lt;br /&gt;JMenuItem = MenuItem&lt;br /&gt;JMenuBar = MenuBar&lt;br /&gt;setJMenuBar = setMenuBar&lt;br /&gt;e.t.c&lt;br /&gt;This can be done because swing has JMenuItem and awt has MenuItem e.t.c.&lt;br /&gt;&lt;br /&gt;The line I had to change more was:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;itemExit.setShortcut(&lt;br /&gt;   new MenuShortcut(&lt;br /&gt;    new KeyEvent&lt;br /&gt;    (this, 1 , 1 ,&lt;br /&gt;     KeyEvent.CTRL_MASK , KeyEvent.VK_X ,&lt;br /&gt;     KeyEvent.CHAR_UNDEFINED ).getKeyCode()&lt;br /&gt;   ));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;which became like this :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;itemExit.setAccelerator(&lt;br /&gt;   KeyStroke.getKeyStroke (KeyEvent.VK_X, KeyEvent.CTRL_MASK)&lt;br /&gt;   );&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;or it could be:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;itemExit.setShortcut(&lt;br /&gt;   new MenuShortcut(KeyStroke.getKeyStroke("X").getKeyCode())&lt;br /&gt;   );&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That's all for now. That worked for me.&lt;br /&gt;If you have any other similar problem please leave it as comment to help others too.&lt;br /&gt;Thank you for visiting.&lt;br /&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2009/01/jmenuitem-not-visible-jmenuitem-behind.html</link><thr:total>0</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-3102605659119615486</guid><pubDate>Sat, 18 Oct 2008 13:28:00 +0000</pubDate><atom:updated>2008-10-18T16:38:19.406+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MIPS</category><title>MIPS Convert a number to another base</title><description>As the titles says here is a mips program converting a given number to a given base. It uses a recursive function named convert. In addition numbers must be positive and also the base must be from 2 to 10.&lt;br /&gt;Here is the assembly code and an output example.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;.data&lt;br /&gt;msg1: .asciiz "Please insert value (A &amp;gt; 0) : "&lt;br /&gt;msg2: .asciiz "Please insert the number system B you want to &lt;br /&gt;convert to (2&amp;lt;=B&amp;lt;=10): "&lt;br /&gt;#Above sting must be in one line&lt;br /&gt;msg3: .asciiz "\nResult : "&lt;br /&gt;.text&lt;br /&gt;.globl main&lt;br /&gt;main:&lt;br /&gt;addi $s0,$zero,2&lt;br /&gt;addi $s1,$zero,10&lt;br /&gt;getA:&lt;br /&gt;&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg1&lt;br /&gt;syscall&lt;br /&gt;li $v0,5&lt;br /&gt;syscall&lt;br /&gt;blt $v0,$zero,getA&lt;br /&gt;&lt;br /&gt;move $t0,$v0&lt;br /&gt;getB:&lt;br /&gt;&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg2&lt;br /&gt;syscall&lt;br /&gt;li $v0,5&lt;br /&gt;syscall&lt;br /&gt;blt $v0,$s0,getB&lt;br /&gt;bgt $v0,$s1,getB&lt;br /&gt;&lt;br /&gt;add $t1,$zero,$v0&lt;br /&gt;&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg3&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;add $a0,$zero,$t0&lt;br /&gt;add $a1,$zero,$t1&lt;br /&gt;&lt;br /&gt;jal convert&lt;br /&gt;&lt;br /&gt;li $v0,10&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;convert:&lt;br /&gt;#a0=A&lt;br /&gt;#a1=B&lt;br /&gt;&lt;br /&gt;addi $sp,$sp,-16&lt;br /&gt;&lt;br /&gt;sw $s3,12($sp) #counter,used to know&lt;br /&gt;#how many times we will pop from stack&lt;br /&gt;sw $s0,8($sp) #A&lt;br /&gt;sw $s1,4($sp) #B&lt;br /&gt;sw $ra,0($sp)&lt;br /&gt;&lt;br /&gt;add $s0,$zero,$a0&lt;br /&gt;add $s1,$zero,$a1&lt;br /&gt;&lt;br /&gt;beqz $s0,end&lt;br /&gt;&lt;br /&gt;div $t4,$s0,$s1 #t4=A/B&lt;br /&gt;rem $t3,$s0,$s1 #t3=A%B&lt;br /&gt;add $sp,$sp,-4&lt;br /&gt;sw $t3,0($sp) #save t3&lt;br /&gt;&lt;br /&gt;add $a0,$zero,$t4 #pass A/B&lt;br /&gt;add $a1,$zero,$s1 #pass B&lt;br /&gt;addi $s3,$s3,1&lt;br /&gt;jal convert        #call convert&lt;br /&gt;&lt;br /&gt;end:&lt;br /&gt;&lt;br /&gt;lw $ra,0($sp)&lt;br /&gt;lw $s1,4($sp)&lt;br /&gt;lw $s0,8($sp)&lt;br /&gt;lw $s3,12($sp)&lt;br /&gt;beqz $s3,done&lt;br /&gt;lw $a0,16($sp)&lt;br /&gt;li $v0,1&lt;br /&gt;syscall&lt;br /&gt;done: &lt;br /&gt;addi $sp,$sp,20&lt;br /&gt;jr $ra   #return&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Please insert value (A &gt; 0) : 15&lt;br /&gt;Please insert the number system B you want&lt;br /&gt;to convert to (2&lt;=B&lt;=10): 2&lt;br /&gt;&lt;br /&gt;Result : 1111&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You may also want to see the &lt;a href="http://akomaenablog.blogspot.com/2008/03/simple-decimal-to-binary-converter.html"&gt; Decimal to Binary converter&lt;/a&gt; or the &lt;a href="http://akomaenablog.blogspot.com/2008/03/simple-binary-to-decimal-converter.html"&gt;Binary to Decimal Converter&lt;/a&gt;&lt;br /&gt;Any comments are appreciated.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/10/mips-convert-number-to-another-base.html</link><thr:total>1</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-5802968285459663381</guid><pubDate>Sat, 18 Oct 2008 13:06:00 +0000</pubDate><atom:updated>2008-10-18T16:20:27.823+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C Programming</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>Strings and Pointers in C - Part 2</title><description>This post is the second part of the Strings and Pointers in C so you may consider reading the &lt;a href="http://akomaenablog.blogspot.com/2008/10/strings-and-pointers-in-c-part-1.html" target="_blank"&gt;Strings and Pointers in C - Part 1&lt;/a&gt; first.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#define N 10&lt;br /&gt;#define M N+N-1&lt;br /&gt;&lt;br /&gt;int main(int argc, char* argv[]) {&lt;br /&gt;char s1[N],s2[N],s[M];&lt;br /&gt;char *a=s1;&lt;br /&gt;char *b=s2;&lt;br /&gt;char *c=s;&lt;br /&gt;&lt;br /&gt;/*input and output s1 &amp; s2 */&lt;br /&gt;printf("Give First String : ");&lt;br /&gt;scanf("%s",a);&lt;br /&gt;printf("String1 is  %s \n",a);&lt;br /&gt;&lt;br /&gt;printf("Give Second String: ");&lt;br /&gt;scanf("%s",b);&lt;br /&gt;printf("String2 is %s\n",b);&lt;br /&gt;printf(" -----------------\n");&lt;br /&gt;&lt;br /&gt;/* copy s1 and s2 to s */&lt;br /&gt;for(; *a!='\0' ; c++,a++)  {&lt;br /&gt;*c=*a;&lt;br /&gt;}&lt;br /&gt;for(; *b!='\0' ; c++,b++)  {&lt;br /&gt;*c=*b;&lt;br /&gt;}&lt;br /&gt;*c='\0';&lt;br /&gt;printf("Two strings together:\n");&lt;br /&gt;for(c=s;((c&amp;lt;s+M) &amp;&amp; (*c!='\0'));c++) {putchar(*c);}&lt;br /&gt;&lt;br /&gt;/* s = s2reversed + s1 reversed */&lt;br /&gt;for(b=s2; *b!='\0' ; b++) {}      /* b = end of s2 */&lt;br /&gt;for(a=s1; *a!='\0' ; a++) {}      /* a = end of s1 */&lt;br /&gt;for (c=s,b--; b!=s2-1 ; c++,b--) {&lt;br /&gt;*c=*b;&lt;br /&gt;}&lt;br /&gt;for (a--; a!=s1-1 ; a--,c++) {&lt;br /&gt;*c=*a;&lt;br /&gt;}&lt;br /&gt;*c='\0';&lt;br /&gt;printf ("\nTwo strings reversed:\n");&lt;br /&gt;for(c=s;((c&amp;lt;s+M) &amp;&amp; (*c!='\0'));c++) {putchar(*c);}&lt;br /&gt;printf("\n -----------------\n");&lt;br /&gt;&lt;br /&gt;/* &lt;br /&gt;   replace same chars with * and replace &lt;br /&gt;   multiple * with one *&lt;br /&gt;*/&lt;br /&gt;a=s1;&lt;br /&gt;b=s2; &lt;br /&gt;c=s;&lt;br /&gt;if (*a==*b){ *c='*';&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;*c=*a;&lt;br /&gt;}   &lt;br /&gt;a++;&lt;br /&gt;b++;&lt;br /&gt;c++;&lt;br /&gt;for (; c&amp;lt;s+N-1; c++,a++,b++) {&lt;br /&gt;    if(*a=='\0') {*c='\0';}&lt;br /&gt;    else {&lt;br /&gt;     if (*a==*b) {&lt;br /&gt;          if (*(c-1)=='*') {c--;}&lt;br /&gt;          else {*c='*';}&lt;br /&gt;     }    &lt;br /&gt;     else { &lt;br /&gt;          *c=*a; &lt;br /&gt;     }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;*c='\0';&lt;br /&gt;printf("\nSame char = *:\n");&lt;br /&gt;for(c=s;((c&amp;lt;s+N) &amp;&amp; (*c!='\0'));c++) {putchar(*c);}&lt;br /&gt;printf("\n -----*END*-----\n");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And finally the third implementation.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#define N 10&lt;br /&gt;#define M N+N-1&lt;br /&gt;&lt;br /&gt;int main(int argc, char* argv[]) {&lt;br /&gt;char *s1=(char*)malloc(sizeof(char)*N);&lt;br /&gt;char *s2=(char*)malloc(sizeof(char)*N);&lt;br /&gt;char *s=(char*)malloc(sizeof(char)*M);&lt;br /&gt;char *temp,*temp1,*temp2;&lt;br /&gt;&lt;br /&gt;/*input and output s1 &amp; s2 */&lt;br /&gt;printf("Give First String : ");&lt;br /&gt;scanf("%s",s1);&lt;br /&gt;printf("String1 is  %s \n",s1);&lt;br /&gt;&lt;br /&gt;printf("Give Second String: ");&lt;br /&gt;scanf("%s",s2);&lt;br /&gt;printf("String2 is %s\n",s2);&lt;br /&gt;printf(" -----------------\n");&lt;br /&gt;&lt;br /&gt;/* copy s1 and s2 to s */&lt;br /&gt;for(temp=s,temp1=s1; *temp1!='\0' ; temp++,temp1++)  {&lt;br /&gt;*temp=*temp1;&lt;br /&gt;}&lt;br /&gt;for(temp=s,temp2=s2; *temp2!='\0' ; temp++,temp2++)  {&lt;br /&gt;*temp=*temp2;&lt;br /&gt;}&lt;br /&gt;*temp='\0';&lt;br /&gt;printf("Two strings together:\n");&lt;br /&gt;for(temp=s;((temp&amp;lt;s+M) &amp;&amp; (*temp!='\0'));temp++) {&lt;br /&gt;    putchar(*temp);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* s = s2reversed + s1 reversed */&lt;br /&gt;for(temp1=s2; *temp1!='\0' ; temp1++) {} /* temp1 = end of s2 */&lt;br /&gt;for(temp2=s1; *temp2!='\0' ; temp2++) {} /* temp2 = end of s1 */&lt;br /&gt;for (temp=s,temp1--; temp1!=s2-1 ; temp++,temp1--) {&lt;br /&gt;*temp=*temp1;&lt;br /&gt;}&lt;br /&gt;for (temp2--; temp2!=s1-1 ; temp2--,temp++) {&lt;br /&gt;*temp=*temp2;&lt;br /&gt;}&lt;br /&gt;*temp='\0';&lt;br /&gt;printf ("\nTwo strings reversed:\n");&lt;br /&gt;for(temp=s;((temp&amp;lt;s+M) &amp;&amp; (*temp!='\0'));temp++) {&lt;br /&gt;   putchar(*temp);&lt;br /&gt;}&lt;br /&gt;printf("\n -----------------\n");&lt;br /&gt;&lt;br /&gt;/* &lt;br /&gt;   replace same chars with * and replace &lt;br /&gt;   multiple * with one *&lt;br /&gt;*/&lt;br /&gt;temp1=s1;&lt;br /&gt;temp2=s2; &lt;br /&gt;temp=s;&lt;br /&gt;if (*temp1==*temp2){ *temp='*';&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;*temp=*temp1;&lt;br /&gt;}   &lt;br /&gt;temp1++;&lt;br /&gt;temp2++;&lt;br /&gt;temp++;&lt;br /&gt;for (; temp&amp;lt;s+N-1; temp++,temp1++,temp2++) {&lt;br /&gt;    if(*temp1=='\0') {*temp='\0';}&lt;br /&gt;    else {&lt;br /&gt;     if (*temp1==*temp2) {&lt;br /&gt;          if (*(temp-1)=='*') {temp--;}&lt;br /&gt;          else {*temp='*';}&lt;br /&gt;     }    &lt;br /&gt;     else { &lt;br /&gt;          *temp=*temp1; &lt;br /&gt;     }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;*temp='\0'; //end of s&lt;br /&gt;printf("\nSame char = *:\n");&lt;br /&gt;for(temp=s;((temp&amp;lt;s+N) &amp;&amp; (*temp!='\0'));temp++) {&lt;br /&gt;    putchar(*temp);&lt;br /&gt;}&lt;br /&gt;printf("\n -----*END*-----\n");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now you can compare the source codes above and make your results.&lt;br /&gt;The output of course is the same for the three programs above.&lt;br /&gt;Here is an output example (playing_with_strings is the executable file after compilation):&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;gt;playing_with_strings&lt;br /&gt;Give First String : computer-blog&lt;br /&gt;String1 is  computer-blog&lt;br /&gt;Give Second String: -another_blog&lt;br /&gt;String2 is -another_blog&lt;br /&gt; -----------------&lt;br /&gt;Two strings together:&lt;br /&gt;-another_blog&lt;br /&gt;Two strings reversed:&lt;br /&gt;golb_rehtona-golb-r&lt;br /&gt; -----------------&lt;br /&gt;Same char = *:&lt;br /&gt;comput*-*&lt;br /&gt; -----*END*-----&lt;br /&gt;&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I hope you enjoyed this long post and got something from it. Thank you for visiting. I am waiting for your comments/suggestions.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/10/strings-and-pointers-in-c-part-2.html</link><thr:total>0</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-3966271376505847136</guid><pubDate>Sat, 18 Oct 2008 12:56:00 +0000</pubDate><atom:updated>2008-10-18T16:16:48.355+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C Programming</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>Strings and Pointers in C - Part 1</title><description>This is another simple program written in C programming language.&lt;br /&gt;The purpose of this program is more educational than useful to anyone.&lt;br /&gt;So, here is the explanation of what it does.&lt;br /&gt;It reads two strings from the user into two tables of chars of size N where N is defined as 10 in this examples.&lt;br /&gt;When the program read both strings it prints the two strings in one then reverse them.&lt;br /&gt;Then prints another string a little more complicated. The last string contains the characters of the first one but when characters at position i of the two strings are the same it places a * as the i-th element. Then replaces continues * with one * and prints the string.&lt;br /&gt;Well, I made three implementations of this "problem".&lt;br /&gt;The first one uses char tables.&lt;br /&gt;The second one uses tables too but instead of getting access directly to table's elements it uses pointers.&lt;br /&gt;The third one uses only pointers.&lt;br /&gt;That's why I said is for educational purposes. The interested reader can find the differences between them and understand better hoe to use pointers.&lt;br /&gt;&lt;br /&gt;here is the first implementation.(with tables only)&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#define N 10&lt;br /&gt;&lt;br /&gt;int main(int argc, char* argv[]) {&lt;br /&gt;char a,s1[N],s2[N],s[N+N-1];&lt;br /&gt;/* s=s1+s2, s=s2reversed+s1reversed, s=* */&lt;br /&gt;int i,j,k;   /* i for s1,j for s2, k for s */&lt;br /&gt;&lt;br /&gt;/*input and output s1 &amp; s2 */&lt;br /&gt;printf("Give First String : ");&lt;br /&gt;scanf("%s",s1);&lt;br /&gt;printf("String1 is  %s \n",s1);&lt;br /&gt;&lt;br /&gt;printf("Give Second String: ");&lt;br /&gt;scanf("%s",s2);&lt;br /&gt;printf("String2 is %s\n",s2);&lt;br /&gt;printf(" ---------------\n");&lt;br /&gt;&lt;br /&gt;/* copy s1 and s2 to s */&lt;br /&gt;for(i=0; s1[i]!='\0' ; i++)  {&lt;br /&gt;s[i]=s1[i];&lt;br /&gt;}&lt;br /&gt;for(j=0; s2[j]!='\0' ; i++,j++)  {&lt;br /&gt;s[i]=s2[j];&lt;br /&gt;}&lt;br /&gt;s[i]='\0';&lt;br /&gt;printf("Two strings together:\n%s\n",s); &lt;br /&gt;&lt;br /&gt;/* s = s2reversed + s1 reversed */&lt;br /&gt;/* may use strlen() instead */&lt;br /&gt;for(j=0; s2[j]!='\0' ; j++) {}      /* j = end of s2 */&lt;br /&gt;for(i=0; s1[i]!='\0' ; i++) {}      /* i = end of s1 */&lt;br /&gt;for (k=0,j--; j&amp;gt;=0 ; k++,j--) {&lt;br /&gt;s[k]=s2[j];&lt;br /&gt;}&lt;br /&gt;for (i--; i&amp;gt;=0 ; i--,k++) {&lt;br /&gt;s[k]=s1[i];&lt;br /&gt;}&lt;br /&gt;s[k]='\0';&lt;br /&gt;printf ("Two strings reversed:\n%s \n");&lt;br /&gt;printf("\n ---------------\n",s);&lt;br /&gt;&lt;br /&gt;/* &lt;br /&gt;   replace same chars with * and replace &lt;br /&gt;   multiple * with one *&lt;br /&gt;*/&lt;br /&gt;i=0;&lt;br /&gt;j=0;&lt;br /&gt;if (s1[i]==s2[i]){ s[i]='*' ; }&lt;br /&gt;else {&lt;br /&gt;s[i]=s1[i];&lt;br /&gt;}&lt;br /&gt;i++;j++ ;   &lt;br /&gt;for (;i&amp;lt;N;i++,j++) {&lt;br /&gt;    if(s1[i]=='\0') { break;}&lt;br /&gt;    else {&lt;br /&gt;     if (s1[i]==s2[i]) {&lt;br /&gt;          if (s[j-1]=='*') {j--;}&lt;br /&gt;          else {s[j]='*';}&lt;br /&gt;     }    &lt;br /&gt;     else { &lt;br /&gt;          s[j]=s1[i]; &lt;br /&gt;     }&lt;br /&gt;    }&lt;br /&gt;}  &lt;br /&gt;s[j]='\0';  //end of s&lt;br /&gt;printf("Same char = *:\n%s",s);&lt;br /&gt;printf("\n -----*END*-----\n");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As I decided to split this post so the reader can open in different windows and compare the implementations,&lt;br /&gt;you can continue with the &lt;a href = "http://akomaenablog.blogspot.com/2008/10/strings-and-pointers-in-c-part-2.html" target="_blank"&gt;Strings and Pointers in C - Part 2&lt;/a&gt; including second and third implementations is here.&lt;br /&gt;Thank you for visiting, reading and commenting.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/10/strings-and-pointers-in-c-part-1.html</link><thr:total>0</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-8217603931879273634</guid><pubDate>Fri, 03 Oct 2008 11:01:00 +0000</pubDate><atom:updated>2008-10-03T14:33:10.694+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>Java RMI and exceptions</title><description>Hello everyone. I know I had a lot of time to post in my blog but I was too busy. Sorry about that.&lt;br /&gt;&lt;br /&gt;Now in this post I want to post some exceptions I had during trying to test an RMI application I was  programming. I will post it as soon as I finish.&lt;br /&gt;&lt;br /&gt;Firstly I wrote a policy file:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;grant {&lt;br /&gt;    permission java.security.AllPermission;&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and saved it in the same directory as policy.all&lt;br /&gt;REMEMBER: I just wanted to test my application. This policy file should only be used for testing and not deployed.&lt;br /&gt;I have all java files for this application in the folder C:\myRMIApp&lt;br /&gt;I opened a console window and typed&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;cd C:\myRMIApp&lt;br /&gt;javac *.java&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After that I had all the classes files.&lt;br /&gt;To run myapp I typed&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;java -Djava.security.policy=policy.all myRMIApp&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where myRMIApp is the name of the class with main().&lt;br /&gt;I got the following exception:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;java.rmi.ConnectException: Connection refused to host: 127.0.0.1;&lt;br /&gt;       nested exception is:&lt;br /&gt;       java.net.ConnectException: Connection refused: connect&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So I remembered that I had to run rmiregistry (I don't comment this :-P)&lt;br /&gt;And this is what I did. I opened another console and executed rmiregistry. (I could use rmiregistry &amp;amp; in the same console)&lt;br /&gt;Anw rmiregistry was running and I tried again to run my application so I typed the same command as above but I got another exception:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;java.rmi.ServerException: RemoteException&lt;br /&gt;   java.rmi.UnmarshalException: error unmarshalling argument&lt;br /&gt;   nested exception is: java.lang.ClassNotFoundException:&lt;br /&gt;   myRMIAppServerInterface&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I was looking my code for mistakes but I couldn't find anything wrong.&lt;br /&gt;After a while I thought to try again with a little difference.&lt;br /&gt;I executed rmiregistry form the C:\myRMIApp&lt;br /&gt;&lt;br /&gt;For my big surprise this solved the above exception and I was able to test my application.&lt;br /&gt;I looked the web but nobody else said that he solved this exception by running rmiregistry in the same directory so I decided to post it and probably help some people ou there having the same problem.&lt;br /&gt;Thank you for visiting and reading. I'm waiting for your comments.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/10/java-rmi-and-exceptions.html</link><thr:total>0</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-1219537892204996313</guid><pubDate>Fri, 20 Jun 2008 20:45:00 +0000</pubDate><atom:updated>2008-06-20T23:48:09.261+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C Programming</category><category domain="http://www.blogger.com/atom/ns#">Computers</category><category domain="http://www.blogger.com/atom/ns#">Internet</category><title>Simple sender/receiver program to calculate the Round Trip Time</title><description>Here are two simple programs, the one named sender and the other named receiver.&lt;br /&gt;Sender is the one who want to calculate the mean Round Trip Delay for the connection between sender and receiver.&lt;br /&gt;So sender sends a hundred (100) packets, sized 1byte each (a char in C programming Language), and wait to get it back from the receiver.&lt;br /&gt;Now it's clear that the receiver just receives packets and send them back without any delay.&lt;br /&gt;Code is after the output.&lt;br /&gt;&lt;br /&gt;When running you will get this output from the receiver:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Connection to sender established&lt;br /&gt;Receive 100 packets of 1 byte and send then back&lt;br /&gt;        Done&lt;br /&gt;Close socket and exit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and from the server:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Sending 100 messages 1 byte each and wait for ack.&lt;br /&gt;RTT = 2.65503e-05 ms&lt;br /&gt;close sockets and exit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here is the code for the receiver which is less complicated than the sender's&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;lt;arpa/inet.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#define SENDER_PORT 3490&lt;br /&gt;#define SENDER_IP "127.0.0.1"&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt;&lt;br /&gt; int sockfd;&lt;br /&gt; int rcv_num,loop_count,i;&lt;br /&gt; char buf;&lt;br /&gt; struct sockaddr_in sender_addr;&lt;br /&gt;&lt;br /&gt; //open socket and connect&lt;br /&gt; if( (sockfd = socket(PF_INET, SOCK_STREAM, 0)) ==-1){&lt;br /&gt;  perror("socket error"); // do some error checking!&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; sender_addr.sin_family = AF_INET;&lt;br /&gt; sender_addr.sin_port = htons(SENDER_PORT);&lt;br /&gt; sender_addr.sin_addr.s_addr = inet_addr(SENDER_IP);&lt;br /&gt; memset(sender_addr.sin_zero, '\0', sizeof(sender_addr.sin_zero));&lt;br /&gt;&lt;br /&gt; if ((connect(sockfd,(struct sockaddr *)&amp;sender_addr,sizeof(sender_addr))) ==-1){&lt;br /&gt;  perror("connect error"); // do some error checking!&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; //connection established&lt;br /&gt; printf("Connection to sender established\n");&lt;br /&gt; //reads 100 packets of 1 byte and sends them back as ack packets&lt;br /&gt; printf("Receive 100 packets of 1 byte and send then back\n");&lt;br /&gt; for(i=0;i&amp;lt;100;i++){&lt;br /&gt;  rcv_num = recv(sockfd,&amp;buf,sizeof(char),0);&lt;br /&gt;  if(rcv_num!=0) {&lt;br /&gt;   //send  ack&lt;br /&gt;   send(sockfd,&amp;buf,sizeof(char),0);&lt;br /&gt;  }&lt;br /&gt;  else{ &lt;br /&gt;   perror("Receive error");&lt;br /&gt;   exit(1);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; printf("\tDone\nClose socket and exit\n");&lt;br /&gt; close(sockfd);&lt;br /&gt; exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you will understand if you look the code above receiver considers sender to be at ip 127.0.0.1. This is the local host. This means that these two programs (sender and receiver) runs locally. This doesn't matter. If you change the SENDER_PORT and the SENDER_IP to the real ones and you run them at two different computers in the world you will have the same output (with different RTT of course)&lt;br /&gt;Well, now it's time for the senders code. I will explain both better in a while.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;lt;arpa/inet.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#define MYPORT 3490&lt;br /&gt;#define SIZE_TO_SEND 1000&lt;br /&gt;#define MY_IP "127.0.0.1"&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt; int sockfd,sockfd2;&lt;br /&gt; char tosend = 's'; //a char (1byte) to send to receivers&lt;br /&gt; char ack;&lt;br /&gt; struct sockaddr_in my_addr,rcvr_addr;&lt;br /&gt; struct timeval start,end;&lt;br /&gt; int sin_size = sizeof(my_addr),i,k,num_packet_sent,optval;&lt;br /&gt; double t1,t2;&lt;br /&gt;&lt;br /&gt; //open TCP socket,bind and accept RECEIVERS connections &lt;br /&gt; if( (sockfd = socket(PF_INET, SOCK_STREAM, 0)) ==-1){&lt;br /&gt;  perror("socket error");&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt; my_addr.sin_family = AF_INET;&lt;br /&gt; my_addr.sin_port = htons(MYPORT);&lt;br /&gt; my_addr.sin_addr.s_addr = inet_addr(MY_IP);&lt;br /&gt; memset(my_addr.sin_zero, '\0', sizeof(my_addr.sin_zero));&lt;br /&gt; //allow reuse of port&lt;br /&gt; optval = 1;&lt;br /&gt; if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&amp;optval,sizeof(int)) == -1) {&lt;br /&gt;  perror("setsockopt");&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt; //bind(socketfd, struct about my address,sizeofmy address);&lt;br /&gt; if (bind(sockfd, (struct sockaddr *)&amp;my_addr, sizeof my_addr) == -1) {&lt;br /&gt;  perror("bind");&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt; listen(sockfd,10);&lt;br /&gt;&lt;br /&gt; sockfd2 = accept(sockfd, (struct sockaddr *)&amp;rcvr_addr, &amp;sin_size);&lt;br /&gt;&lt;br /&gt; //connections OK&lt;br /&gt; //send 100 packet of size 1 byte and for each send wait for ack&lt;br /&gt; t1=0.0; t2=0.0;&lt;br /&gt; printf("Sending 100 messages 1 byte each and wait for ack.\n");&lt;br /&gt; for(num_packet_sent=0;num_packet_sent&amp;lt;100;num_packet_sent++){&lt;br /&gt;  if(gettimeofday(&amp;start,NULL)) {&lt;br /&gt;   printf("time failed\n");&lt;br /&gt;   exit(1);&lt;br /&gt;  }&lt;br /&gt;  send(sockfd2,&amp;tosend,sizeof(char),0);&lt;br /&gt;  optval=recv(sockfd2,&amp;ack,sizeof(char),0);&lt;br /&gt;  if(optval==-1) {&lt;br /&gt;   perror("Receive error");&lt;br /&gt;   exit(1);&lt;br /&gt;  }&lt;br /&gt;  else{&lt;br /&gt;   if(gettimeofday(&amp;end,NULL)) {&lt;br /&gt;    printf("time failed\n");&lt;br /&gt;    exit(1);&lt;br /&gt;   }&lt;br /&gt;             t1+=start.tv_sec+(start.tv_usec/1000000.0);&lt;br /&gt;             t2+=end.tv_sec+(end.tv_usec/1000000.0);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; //calculate and print mean rtt&lt;br /&gt; printf("RTT = %g ms\n",(t2-t1)/100);&lt;br /&gt; printf("close sockets and exit\n");&lt;br /&gt; shutdown(sockfd2,2);&lt;br /&gt; shutdown(sockfd,2);&lt;br /&gt; exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now let's explain these lines.&lt;br /&gt;Both sender and receiver uses the command socket() to open a socket for the communication. Receiver uses connect() with arguments a struct sockaddr_in to connect to the sender. Sender uses bind() to give the sockfd the local address so that it can then call accept and connect to the receiver. After bind() the   sender calls accept() which block until somebody connects (call connect()) to the socket.&lt;br /&gt;When connection is established sender send 100 packets , every one is 1byte (char tosend) and receives another one back. Double t1 sume the start times (before send()) and double t2 sums the end times(after recv()). When all 100 packets are sent RTT is calculated by (t2-t1)/100&lt;br /&gt;This is better than calculate rtt for every packet and then sum them and divide by 100.&lt;br /&gt;&lt;br /&gt;Sum ( t2i-t1i ) / 100 equals ( sum(t2i)-sum(t1i) ) / 100  for 0 &lt;= i &lt; 100&lt;br /&gt;&lt;br /&gt;I don't think I have to say more. If you want to ask something just post it and I will come back to you or send me a mail.&lt;br /&gt;Thank you.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/06/simple-senderreceiver-program-to.html</link><thr:total>12</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-978868979488479597</guid><pubDate>Tue, 17 Jun 2008 12:56:00 +0000</pubDate><atom:updated>2008-06-17T16:10:46.073+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C Programming</category><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>C Program to execute shell script</title><description>As I promised in my previous post &lt;a href="http://akomaenablog.blogspot.com/2008/06/suse-linux-view-cpu-speed-and-hard.html"&gt;Suse Linux View CPU speed and Hard disk/CPU temperature&lt;/a&gt; I am back to publish my little C program which executes the script. Actually I extended it a little so it can execute any script witch is given as argument and it is located in the same directory with the executable (after compiling the code below).&lt;br /&gt;&lt;br /&gt;Well,&lt;br /&gt;The first think needed was how to execute a script.&lt;br /&gt;I first though was fork() and execv().&lt;br /&gt;But after a while I remember that I could use the command system() with argument the script path.&lt;br /&gt;&lt;br /&gt;The second think I needed to know was the directory path of execution.&lt;br /&gt;This isn't that difficult, you can have the directory path with the command getenv("PWD");&lt;br /&gt;&lt;br /&gt;Here is the first version of my little program witch executes only the script in &lt;a href="http://akomaenablog.blogspot.com/2008/06/suse-linux-view-cpu-speed-and-hard.html"&gt;Suse Linux View CPU speed and Hard disk/CPU temperature&lt;/a&gt; post.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#define MAXPATH 127&lt;br /&gt;int main(int argc,char* argv[]){&lt;br /&gt; char *path = malloc(MAXPATH);&lt;br /&gt; path = getenv("PWD");&lt;br /&gt; if(path!=NULL) {&lt;br /&gt;  strcpy(path+(strlen(path)),"/temperature");&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  printf("Couldn't find script\n");&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt; printf("Executing script : %s\n",path);&lt;br /&gt; if(system(path)){&lt;br /&gt;  perror("error\n");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After compiling the above and executing you get the output:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Executing script : /blabla/blabla/temperature&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature       = 51&lt;br /&gt;  Hard disk Temperature = 53&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Cool isn't it?&lt;br /&gt;But it wasn't really useful to exec the program every time to see the results...&lt;br /&gt;So I modified it again to take as argument two integers. &lt;br /&gt;The one was how many times to exec script and the other how many seconds to sleep between executions.&lt;br /&gt;After that I told my self, why don't you make it to keep a log file for you?&lt;br /&gt;So I did. I added ability to print time (to see how see the code below), and to run in a infinite loop if repeat times = -1.&lt;br /&gt;I didn't make a file cos I am a little lazy, I just used the operator &gt; to redirect output to a file!!!&lt;br /&gt;And after that I though it would be useful to others if it was able to exec any script, so I modified it again to take the script name as argument.&lt;br /&gt;&lt;br /&gt;Finally here is the final version (for me at least):&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;lt;time.h&amp;gt;&lt;br /&gt;&lt;br /&gt;#define MAXPATH 127&lt;br /&gt;#define DEFAULTVALUE 5&lt;br /&gt;int main(int argc,char* argv[]){&lt;br /&gt; if (argc!=4 &amp;&amp; argc!=2) {&lt;br /&gt;  printf("Usage : \n %s \"script file\" \"sleeptime in sec\" &lt;br /&gt;                                \"repeat times\"\n",argv[0]);&lt;br /&gt;  exit(0);&lt;br /&gt; }&lt;br /&gt; char *path = malloc(MAXPATH);//MAXPATH chars&lt;br /&gt; path = getenv("PWD");&lt;br /&gt; if(path!=NULL) {&lt;br /&gt;  strcpy(path+(strlen(path)),"/"); //add / to the end&lt;br /&gt;  strcpy(path+(strlen(path)),argv[1]); //add the script file to the end&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  printf("Couldn't find path\n");&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt; int repeat,sleep_sec,i;&lt;br /&gt; if(argc==4) {&lt;br /&gt;  sleep_sec = atoi(argv[2]);&lt;br /&gt;  if(sleep_sec&amp;lt;0) sleep_sec = DEFAULTVALUE;&lt;br /&gt;  repeat = atoi(argv[3]);&lt;br /&gt;  if(repeat&amp;lt;0 &amp;&amp; repeat!=-1) repeat = DEFAULTVALUE;&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  repeat = DEFAULTVALUE;&lt;br /&gt;  sleep_sec = DEFAULTVALUE;&lt;br /&gt; }&lt;br /&gt; i=0;&lt;br /&gt; time_t t;&lt;br /&gt; if(repeat!= -1) {&lt;br /&gt;  printf("Executing script : %s %d times every %d seconds\n",&lt;br /&gt;                                           path,repeat,sleep_sec);&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt;  printf("Executing script : %s every %d seconds\n",path,sleep_sec);&lt;br /&gt; }&lt;br /&gt; while( repeat == -1 ||  i&amp;lt;repeat) {&lt;br /&gt;  sleep(sleep_sec);&lt;br /&gt;  time(&amp;t);&lt;br /&gt;  printf("\t%s", asctime(localtime(&amp;t))); //print current time&lt;br /&gt;  fflush(stdout); //force write date and time&lt;br /&gt;  if(system(path)){ //execute script&lt;br /&gt;   perror("error\n");&lt;br /&gt;  }&lt;br /&gt;  i++;&lt;br /&gt; }&lt;br /&gt; printf("\n");&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And the output looks like that:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;:/blabla/blabla # ./temperature2&lt;br /&gt;Usage :&lt;br /&gt; ./t2 "script file" "sleeptime in sec" "repeat times"&lt;br /&gt;:/blabla/blabla # ./temperature2 temperature 2 3&lt;br /&gt;Executing script : /blabla/blabla/temperature 3 times every 2 seconds&lt;br /&gt;        Tue Jun 17 15:38:39 2008&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature       = 50&lt;br /&gt;  Hard disk Temperature = 52&lt;br /&gt;        Tue Jun 17 15:38:41 2008&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature       = 51&lt;br /&gt;  Hard disk Temperature = 52&lt;br /&gt;        Tue Jun 17 15:38:43 2008&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature       = 51&lt;br /&gt;  Hard disk Temperature = 52&lt;br /&gt;&lt;br /&gt;:/blabla/blabla #&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now you can use it like that to keep a log file:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;:/blabla/blabla # ./temperature2 temperature 30 -1 &amp;gt; temp_log_file.txt &amp;&lt;br /&gt;16716    &amp;lt;--- this is the pid of the new proccess.&lt;br /&gt;:/blabla/blabla # &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now it is running in the background and you will notice the file temp_log_file.txt in the directory.&lt;br /&gt;&lt;br /&gt;To stop the process use:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;kill 16716&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;replace 16716 with the correct pid. If you don't remember it use ps to find it.&lt;br /&gt;You may don't want to kill it as it only uses about 1kb of memory...&lt;br /&gt;After all OS will send the kill signal at shutdown!&lt;br /&gt;&lt;br /&gt;I forgot to show you my log file. Here it is.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Executing script : /blabla/blabla/temperature every 30 seconds&lt;br /&gt; Tue Jun 17 15:55:04 2008&lt;br /&gt;  current CPU frequency is 2.00 GHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature = 51&lt;br /&gt;  Hard disk Temperature = 52&lt;br /&gt; Tue Jun 17 15:55:34 2008&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature = 51&lt;br /&gt;  Hard disk Temperature = 52&lt;br /&gt; Tue Jun 17 15:56:04 2008&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature = 51&lt;br /&gt;  Hard disk Temperature = 52&lt;br /&gt; Tue Jun 17 15:56:35 2008&lt;br /&gt;  current CPU frequency is 2.00 GHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature = 51&lt;br /&gt;  Hard disk Temperature = 52&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I hope you like. Thank you for visiting and reading my posts.&lt;br /&gt;Comments appreciated.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/06/c-program-to-execute-shell-script.html</link><thr:total>1</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-4424930671192565096</guid><pubDate>Tue, 17 Jun 2008 12:07:00 +0000</pubDate><atom:updated>2008-06-17T15:11:48.586+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><title>Summer Computer Tips</title><description>#1 – Summer Computer Travel&lt;br /&gt;Holiday travelers should be on alert when arriving home from long weekends, such as the Fourth of July, a popular time for computer viruses to spread. &lt;br /&gt;&lt;br /&gt;Most computer users have a tendency to turn off their computers when away on trips, which means you’re not getting newly-released anti-virus patches or anti-spyware updates; the two most common areas that cause computers problems. We recommend you update anti-virus and anti-spyware scans before opening e-mail or going online after an extended absence. &lt;br /&gt;&lt;br /&gt;We consistently see an increase in calls for virus related problems immediately following long weekends. Avoid the problems altogether by updating your security software before using your computer. For a free listing of viruses, spyware threats and trends, visit: www.VisitingGeeks.com/downloads.htm &lt;br /&gt;&lt;br /&gt;#2 -- Should You Leave Your Computer Running?&lt;br /&gt;One question we hear frequently is, "Should I leave my desktop computer on or turn it off?"&lt;br /&gt;There are 2 schools of thought…&lt;br /&gt;Turning it on and off numerous times during the day subjects the microcircuits to flexing and fatigue due to change in temperatures. Over time this could lead to a break in the circuitry and result in system failure.&lt;br /&gt;Leaving the computer on all the time puts excess wear on the mechanical components (the hard drive spindle motor and cooling fans).&lt;br /&gt;Best compromise. First user in the morning turns it on; last user turns it off.&lt;br /&gt;We leave our desktops on all the time allowing for scheduled utility tasks to run during overnight hours. We also restart the systems (to flush the RAM and reset the operating system) on a regular basis and routinely remove the case covers to clean out any dust that may have accumulated, especially around the fans and screens.&lt;br /&gt;&lt;br /&gt;#3 -- Stop Popups!&lt;br /&gt;Never click inside the window of a popup. Instead, close it by clicking on the X in the upper right corner. Many people are fooled into installing spyware applications by popups that promise to clean their system. If you receive a message saying it can help, assume it’s spyware and don’t click!&lt;br /&gt;&lt;br /&gt; About the author:&lt;br /&gt;Sharron Senter is co-founder of &lt;a href='http://www.VisitingGeeks.com' target='_blank' rel="nofollow"&gt;http://www.VisitingGeeks.com&lt;/a&gt;- an on site computer repair, security and networking company serving north of Boston, Southern NH and Maine. Visiting Geeks’ technicians are crackerjacks at squashing viruses, popups and securing and making computers perform faster. Learn more about Sharron at &lt;a href='http://www.SharronSenter.com' target='_blank' rel="nofollow"&gt;http://www.SharronSenter.com&lt;/a&gt;&lt;br /&gt;  &lt;font size="-2"&gt;Circulated by &lt;a href="http://www.article-emporium.com" target='_blank' rel="nofollow"&gt;Article Emporium&lt;/a&gt;&lt;/font&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/06/summer-computer-tips.html</link><thr:total>0</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-5491065686354043600</guid><pubDate>Tue, 10 Jun 2008 12:19:00 +0000</pubDate><atom:updated>2008-12-11T22:59:07.398+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Computers</category><category domain="http://www.blogger.com/atom/ns#">Internet</category><title>Use your gmail space as a local drive to store your files</title><description>How can I use my Gmail space to save any file I want?&lt;br /&gt;The answer is very very simple and exciting!!!!&lt;br /&gt;Download and install &lt;a href="http://www.softpedia.com/progDownload/GMail-Drive-shell-extension-Download-15944.html#download_locations" target="_blank" rel="nofollow"&gt;GMail Drive Shell Extension&lt;/a&gt;&lt;br /&gt;After installing open My Computer folder and you will see another drive appear named GMail Drive as shown in the image below.&lt;br /&gt;You can use it as a normal drive (like C:\)!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtibgVsQ4FHPI9Yh1lnS8n3DGlJdauEXr9TIPSausrGdVdWbFpjWYaH9jyaY0L_4azPobcPtTOzKZtO5JaSv65LFP7ARoV2nSn3rmhDnoYNsSJcHtSOldU5ibvkUaVNBVsNZRHLdRYWg/s1600-h/mycomputer2.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtibgVsQ4FHPI9Yh1lnS8n3DGlJdauEXr9TIPSausrGdVdWbFpjWYaH9jyaY0L_4azPobcPtTOzKZtO5JaSv65LFP7ARoV2nSn3rmhDnoYNsSJcHtSOldU5ibvkUaVNBVsNZRHLdRYWg/s400/mycomputer2.JPG" alt="" id="BLOGGER_PHOTO_ID_5210226854471678178" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Double click to open and you will get a window telling you to login.&lt;br /&gt;Fill in your google account user name and password and click OK.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSmZHSVRugX4A-JAwDUexjFvvBq5LoP_J_yBV_O_Lf3xBMJeKNivOPiZQ7H51-xeAVy2RXmrpqMUK-JPeu4vJ7SnuwQzJM9pnOF5TKDAhES4RpLCIuAMTOVO8KTUlDHM4DBsFV60c10Q/s1600-h/login.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSmZHSVRugX4A-JAwDUexjFvvBq5LoP_J_yBV_O_Lf3xBMJeKNivOPiZQ7H51-xeAVy2RXmrpqMUK-JPeu4vJ7SnuwQzJM9pnOF5TKDAhES4RpLCIuAMTOVO8KTUlDHM4DBsFV60c10Q/s400/login.JPG" alt="" id="BLOGGER_PHOTO_ID_5210226743531241890" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;After this you will see a new window like the one in the picture below and then an opened window where you can paste any files you want.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ2w1A1Yj5MEwAc6t6INU70gMXDguRPtal7vGI4j9hCDfCF8WDO-_0AXWR9fNl2fcj2DWUToTTgvG-8TwtL5S7ePiDOcAP82N7_QTD-TGnFE4VqSk2mQql0m5zNUND3bp5AiOceezPoA/s1600-h/login2.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ2w1A1Yj5MEwAc6t6INU70gMXDguRPtal7vGI4j9hCDfCF8WDO-_0AXWR9fNl2fcj2DWUToTTgvG-8TwtL5S7ePiDOcAP82N7_QTD-TGnFE4VqSk2mQql0m5zNUND3bp5AiOceezPoA/s400/login2.JPG" alt="" id="BLOGGER_PHOTO_ID_5210226636048380738" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;If you use it you will notice that you get a new mail in your inbox for every file you paste.&lt;br /&gt;&lt;br /&gt;If you don't like it there is a solution.&lt;br /&gt;&lt;br /&gt;Go to your gmail and click Settings (up right)&lt;br /&gt;Go to the tab Filters and select Create a new filter&lt;br /&gt;To the Subject write GMAILFS (leave others blank)&lt;br /&gt;and click Next Step &gt;&gt;&lt;br /&gt;Tick Skip the Inbox (Archive it) and Mark as read (and any other you want)&lt;br /&gt;If you want to add a label (I suggest you do)&lt;br /&gt;select Apply the label: Choose Label... and from the drop down list&lt;br /&gt;select a label you already have or New Label... and in the pop -up window enter the label you want(e.g. my_files)&lt;br /&gt;&lt;br /&gt;Finally click Create Filter&lt;br /&gt;&lt;br /&gt;If you done the above steps right you won't get a new mail every time you add a new file to your GMail Drive!&lt;br /&gt;You can see these new mails in the folder All Mail and also in the folder Starred if you selected Star it before.&lt;br /&gt;&lt;br /&gt;Also GMail Drive Shell Extension bypasses the limitation of storing .exe files or other formats by renaming the file as filename.exe_renamed&lt;br /&gt;This don't affect you in any way because you can see/execute it normally in/from your new drive.&lt;br /&gt;&lt;br /&gt;Enjoy your new Drive and also keep in mind that what you're doing may violate Gmail's TOS, so you may want to register another account...&lt;br /&gt;I'm expecting your comments.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/06/use-your-gmail-space-as-gmail-drive-to.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtibgVsQ4FHPI9Yh1lnS8n3DGlJdauEXr9TIPSausrGdVdWbFpjWYaH9jyaY0L_4azPobcPtTOzKZtO5JaSv65LFP7ARoV2nSn3rmhDnoYNsSJcHtSOldU5ibvkUaVNBVsNZRHLdRYWg/s72-c/mycomputer2.JPG" width="72"/><thr:total>2</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-7584319156347276393</guid><pubDate>Thu, 05 Jun 2008 20:11:00 +0000</pubDate><atom:updated>2008-06-05T23:50:37.144+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Hardware</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><title>Suse Linux View CPU speed and Hard disk/CPU temperature</title><description>I have a laptop which sometime goes really hot and I wanted a simple way to be able to view CPU and Hard disk temperature. I' m on SUSE 10.3 and I tried installing LM-sensors but no sensors were detected. After a very little search I found that you can view the CPU speed by using the cpufrequtils so I installed the package using Yast and executed  cpufreq-info.&lt;br /&gt;Here is the output:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006&lt;br /&gt;Report errors and bugs to http://bugs.opensuse.org, please.&lt;br /&gt;analyzing CPU 0:&lt;br /&gt;  driver: acpi-cpufreq&lt;br /&gt;  CPUs which need to switch frequency at the same time: 0&lt;br /&gt;  hardware limits: 798 MHz - 2.00 GHz&lt;br /&gt;  available frequency steps: 2.00 GHz, 1.60 GHz, 1.33 GHz, 1.06 GHz, 798 MHz&lt;br /&gt;  available cpufreq governors: conservative, userspace, powersave, ondemand, performance&lt;br /&gt;  current policy: frequency should be within 798 MHz and 2.00 GHz.&lt;br /&gt;                  The governor "ondemand" may decide which speed to use&lt;br /&gt;                  within this range.&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I was a little excited but I wanted to view the CPU and the hard disk temperature too.&lt;br /&gt;I found that I could see CPU temperature with the command:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;cat /proc/acpi/thermal_zone/THRM/temperature&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and the hard disk temperature (and some other stuff if you don't use grep) with&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;smartctl -d ata -A /dev/sda3 | grep -i temperature&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where sda3 is my hard disk partition where linux are installed but actually it doesn't matter. ( I think :-P)&lt;br /&gt;&lt;br /&gt;Now we know the commands and we have the tools we need.&lt;br /&gt;But hold on a second, Can't we make it better?&lt;br /&gt;Of course we can, we are talking about computers here!&lt;br /&gt;So I wrote this simple shell script&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;cpufreq-info |&lt;br /&gt;grep -i "current CPU frequency";&lt;br /&gt;cat /proc/acpi/thermal_zone/THRM/temperature |&lt;br /&gt;awk '{ printf("  CPU Temperature\t= " $2"\n") }';&lt;br /&gt;smartctl -d ata -A /dev/sda3 |&lt;br /&gt;grep -i temperature |&lt;br /&gt;awk '{ printf("  Hard disk Temperature = " $10"\n") }'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and saved it in a file named temperature.&lt;br /&gt;I gave it execution permission using&lt;br /&gt;chmod +x temperature&lt;br /&gt;and I was able to see the CPU speed and temperature and the Hard disk temperature too&lt;br /&gt;by using &lt;br /&gt;./temperature&lt;br /&gt;and that's it.&lt;br /&gt;This is my output.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;blablabla/Temperature # ./temperature&lt;br /&gt;  current CPU frequency is 798 MHz (asserted by call to hardware).&lt;br /&gt;  CPU Temperature       = 51&lt;br /&gt;  Hard disk Temperature = 54&lt;br /&gt;&lt;br /&gt;blablabla/Temperature # &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Yeap, a little hot, but it can be hotter so it's ok... :-P&lt;br /&gt;After that I wrote a little C code to have the script executed&lt;br /&gt;from a program but I will explain it in another post very soon!&lt;br /&gt;&lt;br /&gt;I hope this work for you too.&lt;br /&gt;Thank you all for visiting,reading and posting your comments.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/06/suse-linux-view-cpu-speed-and-hard.html</link><thr:total>2</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-2321722011198567951</guid><pubDate>Fri, 30 May 2008 16:10:00 +0000</pubDate><atom:updated>2008-05-30T19:35:55.952+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C Programming</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>C Example to Reverse a file</title><description>This an example how to reverse a file. It is based on recursion.&lt;br /&gt;The idea is to read all the file and when you reach the end(EOF) print them.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;void reverse(FILE * file) {&lt;br /&gt; int fscanf_return_value;&lt;br /&gt; char x;&lt;br /&gt; /* read a char */&lt;br /&gt; fscanf_return_value = fscanf(file,"%c",&amp;x) ;&lt;br /&gt; if(fscanf_return_value == EOF) { //fscanf returns EOF as the END OF FILE&lt;br /&gt;  return;&lt;br /&gt; }&lt;br /&gt; reverse(file); //Get the next char&lt;br /&gt; //do something with the char e.g. print&lt;br /&gt; putchar(x);&lt;br /&gt; return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt; int i;&lt;br /&gt; FILE *fd;&lt;br /&gt; if (argc!=2) {&lt;br /&gt;  printf("Usage : \n %s FILENAME\n",argv[0]);&lt;br /&gt;  exit(0);&lt;br /&gt; }&lt;br /&gt; if(!(fd=fopen(argv[1],"r"))) {&lt;br /&gt;  printf("Opening file error\n");&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt; reverse(fd);&lt;br /&gt; printf("\n\n\t---\tenoD - Done\t---\n");&lt;br /&gt; close(fd);&lt;br /&gt; exit(0);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To run it just give it argument the name of the file you want.&lt;br /&gt;For example if the code above is in a file named reverse.c &lt;br /&gt;and compiled with the command&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;gcc reverse.c -o reverse&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;just type in the konsole&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;./reverse reverse.c&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and you will get the output bellow.&lt;br /&gt;If you want to save it to another file the easiest way to do it&lt;br /&gt;is to execute&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;./reverse reverse.c &amp;gt;&amp;gt; output.txt&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Example of output is:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;}&lt;br /&gt;;)0(tixe &lt;br /&gt;;)df(esolc &lt;br /&gt;;)"n\---t\enoD - Donet\---t\n\n\"(ftnirp &lt;br /&gt;;)df(esrever &lt;br /&gt;} &lt;br /&gt;;)1(tixe  &lt;br /&gt;;)"n\rorre elif gninepO"(ftnirp  &lt;br /&gt;{ )))"r",]1[vgra(nepof=df(!(fi &lt;br /&gt;} &lt;br /&gt;;)0(tixe  &lt;br /&gt;;)]0[vgra,"n\EMANELIF s% n\ : egasU"(ftnirp  &lt;br /&gt;{ )2=!cgra( fi &lt;br /&gt;;df* ELIF &lt;br /&gt;;i tni &lt;br /&gt;{ )][vgra* rahc ,cgra tni(niam tni&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;;nruter &lt;br /&gt;;)x(rahctup &lt;br /&gt;tnirp .g.e rahc eht htiw gnihtemos od// &lt;br /&gt;rahc txen eht teG// ;)elif(esrever &lt;br /&gt;} &lt;br /&gt;;nruter  &lt;br /&gt;ELIF FO DNE eht sa FOE snruter fnacsf// { )FOE == eulav_nruter_fnacsf(fi &lt;br /&gt;; )x&amp;,"c%",elif(fnacsf = eulav_nruter_fnacsf &lt;br /&gt;/* rahc a daer */ &lt;br /&gt;;x rahc &lt;br /&gt;;eulav_nruter_fnacsf tni &lt;br /&gt;{ )elif * ELIF(esrever diov&lt;br /&gt;&lt;br /&gt;&amp;gt;h.bildts&amp;lt; edulcni#&lt;br /&gt;&amp;gt;h.oidts&amp;lt; edulcni#&lt;br /&gt;&lt;br /&gt; --- enoD - Done ---&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I think it is a simple to understand example.&lt;br /&gt;Another way to do it is to use fseek(FILE,SEEK_END) to move the pointer in the file at the end and then start reading a char,do something with it,use fseek(FILE,-1,SEEK_CUR) to move the pos one char back and do this untill you reach the SEEK_SET.&lt;br /&gt;i hope this was helpful. Please post any comments you have.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/05/c-example-to-reverse-file.html</link><thr:total>2</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-6381581480234685232</guid><pubDate>Tue, 27 May 2008 19:26:00 +0000</pubDate><atom:updated>2008-05-29T12:42:22.909+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computer Tips</category><category domain="http://www.blogger.com/atom/ns#">Computers</category><title>Microsoft Word 2003 does not print page border</title><description>As the title says today I had a problem with Microsoft word. The page border wasn't printed correctly. Here are the steps to correct it(At least worked for me)&lt;br /&gt;Go to:&lt;br /&gt;- File menu&lt;br /&gt;- Page Setup...&lt;br /&gt;- Select the tab Paper&lt;br /&gt;- Down the Paper Size select Custom Size&lt;br /&gt;- and set Width = 21cm and height = 29cm&lt;br /&gt;- Down to Preview select Apply to Whole Document&lt;br /&gt;and click ok&lt;br /&gt;&lt;br /&gt;That worked for me, the page border was printed correctly. I hope this work for you too.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/05/microsoft-word-2003-doesnt-print-page.html</link><thr:total>2</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-1638718520542730639</guid><pubDate>Tue, 13 May 2008 18:58:00 +0000</pubDate><atom:updated>2008-05-13T22:06:49.368+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Computers</category><category domain="http://www.blogger.com/atom/ns#">Hardware</category><title>Nec ND-6650A Read Error Fixed</title><description>I recently came across a reading problem of my nd 6650A dvd-rw drive.&lt;br /&gt;My dvd is a Nec ND6650A and my laptop is Fujitsu Siemens Amilo M series.&lt;br /&gt;My dvd-rw drive wasn't able to read a lot of dvds (both DVD-R and DVD+R).&lt;br /&gt;I burned some dvds with importand to me data using nero burning software. &lt;br /&gt;I also run data verification for every disc and all finished successfuly.&lt;br /&gt;After that my ND6650A couldn't read them. Isn't that weird?&lt;br /&gt;I though that maybe a firmware update would solve the problem so I searched the net for firmware update.&lt;br /&gt;Neither Nec official site nor FujitsuSiemens site had any update.&lt;br /&gt;After a little search I went to &lt;a href="http://liggydee.cdfreaks.com/page/en/NEC-ND-6650A/"&gt;Liggy's and Dee's NEC 6650 firmware&lt;/a&gt; site.&lt;br /&gt;From this great site, for me, I downloaded and tried enough original versions but none of them solved the problem.&lt;br /&gt;I decided that I should buy a new one and I started looking around.&lt;br /&gt;But the next day I though "Why I don't try to flash again with some more firmwares? What do I have to loose? Drive is not working anw..."&lt;br /&gt;So I went again to Liggy's and Dee's site and I tried Liggy's 1.62 Bitsetting Firmware RPC1.&lt;br /&gt;For my surprise that modified firmware solved the problem.&lt;br /&gt;Now my drive is working as it was before and it's region free too!&lt;br /&gt;Thank you a lot Liggy and Dee. You saved me from buying a new dvd rw drive.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/05/nec-nd-6650a-read-error-fixed.html</link><thr:total>1</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-7213151550658248942</guid><pubDate>Wed, 07 May 2008 13:36:00 +0000</pubDate><atom:updated>2008-05-07T16:51:02.262+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>Simple Java Menu</title><description>This is another simple Java example on how to implement a console menu interface with the user.&lt;br /&gt;The steps are really simple.&lt;br /&gt;   In a loop:&lt;br /&gt;    a) A String which contains the menu options is printed.&lt;br /&gt;    b) A number from keyboard is read.&lt;br /&gt;    c) Using switch - case statement the correct method is called.&lt;br /&gt;The following Java code is showing the above steps.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import java.util.Scanner;&lt;br /&gt;&lt;br /&gt;public class SimpleMenu {&lt;br /&gt;   public void start(){&lt;br /&gt;       Scanner keyboard = new Scanner(System.in);&lt;br /&gt;       int choice;&lt;br /&gt;       String menu = "Options\n";&lt;br /&gt;       menu+="1. Choice1\n";&lt;br /&gt;       menu+="2. Choice2\n";&lt;br /&gt;       menu+="3. Choice3\n";&lt;br /&gt;       menu+="4. Exit\n";&lt;br /&gt;       menu+="Select an option : ";&lt;br /&gt;       while(true) {&lt;br /&gt;      System.out.print(menu);&lt;br /&gt;      choice = keyboard.nextInt();&lt;br /&gt;           switch (choice) {&lt;br /&gt;         case 1: choice1(); break;&lt;br /&gt;         case 2: choice2(); break;&lt;br /&gt;         case 3: choice3(); break;&lt;br /&gt;         case 4: System.exit(0); break;&lt;br /&gt;         default: &lt;br /&gt;                    System.out.println("Invalid choice.");&lt;br /&gt;                    break;&lt;br /&gt;           }&lt;br /&gt;   }&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   private void choice1(){&lt;br /&gt; System.out.println("Menu example choice 1");&lt;br /&gt;   }&lt;br /&gt;   private void choice2(){&lt;br /&gt; System.out.println("Menu example choice 2");&lt;br /&gt;   }&lt;br /&gt;   private void choice3(){&lt;br /&gt; System.out.println("Menu example choice 3");&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;    new SimpleMenu().start();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/05/simple-java-menu.html</link><thr:total>1</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-4250083290729915995</guid><pubDate>Fri, 11 Apr 2008 08:14:00 +0000</pubDate><atom:updated>2008-04-11T11:17:05.107+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MIPS</category><title>MIPS NON recursive Fibonacci</title><description>MIPS NON recursive Fibonacci&lt;br /&gt;&lt;br /&gt;As you may seen I posted an implementation of &lt;a href="http://akomaenablog.blogspot.com/2008/04/fibonacci-in-c.html"&gt;Fibonacci in C&lt;/a&gt;(recursive and not) and &lt;a href="http://akomaenablog.blogspot.com/2008/04/mips-recursive-fibonacci.html"&gt;Recursive Fibonacci MIPS&lt;/a&gt;.&lt;br /&gt;You may also want to see &lt;a href="http://akomaenablog.blogspot.com/search/label/MIPS"&gt;All my MIPS examples&lt;/a&gt;.&lt;br /&gt;Here is the NON recursive implementation of Fibonacci for MIPS.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;.data&lt;br /&gt;msg1:.asciiz "Give a number : "&lt;br /&gt;.text&lt;br /&gt;.globl main&lt;br /&gt;main:&lt;br /&gt;&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg1&lt;br /&gt;syscall&lt;br /&gt;li $v0,5&lt;br /&gt;syscall&lt;br /&gt;add $a0,$v0,$zero&lt;br /&gt;&lt;br /&gt;jal fib&lt;br /&gt;&lt;br /&gt;add $a0,$v0,$zero&lt;br /&gt;li $v0,1&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;li $v0,10&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;fib:&lt;br /&gt;#a0=a&lt;br /&gt;#if (a==0) return 0;&lt;br /&gt;#if (a==1) return 1;&lt;br /&gt;  &lt;br /&gt;#    int x($t1),y($t2),z($t3),i($t4);&lt;br /&gt;#    for (x=0,y=0,z=1,i=1;i&amp;lt;a;i++) {&lt;br /&gt;#        x=y+z;&lt;br /&gt;#        y=z;&lt;br /&gt;#        z=x;   }   &lt;br /&gt;&lt;br /&gt;#    return(x);&lt;br /&gt;    &lt;br /&gt;addi $t0,$zero,1&lt;br /&gt;&lt;br /&gt;beqz $a0,return0&lt;br /&gt;beq $a0,$t0,return1&lt;br /&gt;&lt;br /&gt;#arxikopiisi&lt;br /&gt;&lt;br /&gt;add $t1,$zero,$zero&lt;br /&gt;add $t2,$zero,$zero&lt;br /&gt;addi $t3,$zero,1&lt;br /&gt;addi $t4,$zero,1&lt;br /&gt;&lt;br /&gt;loop:&lt;br /&gt;bge $t4,$a0,endloop&lt;br /&gt;add $t1,$t2,$t3&lt;br /&gt;add $t2,$zero,$t3&lt;br /&gt;add $t3,$zero,$t1&lt;br /&gt;addi $t4,$t4,1&lt;br /&gt;j loop&lt;br /&gt;&lt;br /&gt;endloop:&lt;br /&gt;add $v0,$zero,$t1&lt;br /&gt;jr $ra&lt;br /&gt;&lt;br /&gt;return0:&lt;br /&gt;add $v0,$zero,$zero&lt;br /&gt;jr $ra&lt;br /&gt;&lt;br /&gt;return1:&lt;br /&gt;addi $v0,$zero,1&lt;br /&gt;jr $ra&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/04/mips-non-recursive-fibonacci.html</link><thr:total>2</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-3147221389428028592</guid><pubDate>Fri, 11 Apr 2008 08:00:00 +0000</pubDate><atom:updated>2008-04-11T11:22:35.497+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MIPS</category><title>MIPS Recursive Fibonacci</title><description>As you may seen I posted an implementation of &lt;a href="http://akomaenablog.blogspot.com/2008/04/fibonacci-in-c.html"&gt;Fibonacci in C&lt;/a&gt;(recursive and not).&lt;br /&gt;I have also posted &lt;a href="http://akomaenablog.blogspot.com/2008/04/mips-non-recursive-fibonacci.html"&gt;Mips Non Recursive Fibonacci&lt;/a&gt;.&lt;br /&gt;Here is the recursive implementation of Fibonacci for MIPS. I have already told this, I suggest you use &lt;a href="http://pages.cs.wisc.edu/~larus/spim.html"&gt;SPIM&lt;/a&gt; to simulate your MIPS programs first.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;.data&lt;br /&gt;msg1:.asciiz "Give a number: "&lt;br /&gt;.text&lt;br /&gt;.globl main&lt;br /&gt;main:&lt;br /&gt;&lt;br /&gt;li $v0,4&lt;br /&gt;la $a0,msg1&lt;br /&gt;syscall #print msg&lt;br /&gt;li $v0,5&lt;br /&gt;syscall #read an int&lt;br /&gt;add $a0,$v0,$zero #move to $a0&lt;br /&gt;&lt;br /&gt;jal fib #call fib&lt;br /&gt;&lt;br /&gt;add $a0,$v0,$zero&lt;br /&gt;li $v0,1&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;li $v0,10&lt;br /&gt;syscall&lt;br /&gt;&lt;br /&gt;fib:&lt;br /&gt;#a0=y&lt;br /&gt;#if (y==0) return 0;&lt;br /&gt;#if (y==1) return 1;&lt;br /&gt;#return( fib(y-1)+fib(y-2) );&lt;br /&gt;&lt;br /&gt;addi $sp,$sp,-12 #save in stack&lt;br /&gt;sw $ra,0($sp)&lt;br /&gt;sw $s0,4($sp)&lt;br /&gt;sw $s1,8($sp)&lt;br /&gt;&lt;br /&gt;add $s0,$a0,$zero&lt;br /&gt;&lt;br /&gt;addi $t1,$zero,1&lt;br /&gt;beq $s0,$zero,return0&lt;br /&gt;beq $s0,$t1,return1&lt;br /&gt;&lt;br /&gt;addi $a0,$s0,-1&lt;br /&gt;&lt;br /&gt;jal fib&lt;br /&gt;&lt;br /&gt;add $s1,$zero,$v0     #s1=fib(y-1)&lt;br /&gt;&lt;br /&gt;addi $a0,$s0,-2&lt;br /&gt;&lt;br /&gt;jal fib               #v0=fib(n-2)&lt;br /&gt;&lt;br /&gt;add $v0,$v0,$s1       #v0=fib(n-2)+$s1&lt;br /&gt;exitfib:&lt;br /&gt;&lt;br /&gt;lw $ra,0($sp)       #read registers from stack&lt;br /&gt;lw $s0,4($sp)&lt;br /&gt;lw $s1,8($sp)&lt;br /&gt;addi $sp,$sp,12       #bring back stack pointer&lt;br /&gt;jr $ra&lt;br /&gt;&lt;br /&gt;return1:&lt;br /&gt; li $v0,1&lt;br /&gt; j exitfib&lt;br /&gt;return0 :     li $v0,0&lt;br /&gt; j exitfib&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/04/mips-recursive-fibonacci.html</link><thr:total>19</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8264121216529648346.post-5454920908182864100</guid><pubDate>Tue, 08 Apr 2008 13:57:00 +0000</pubDate><atom:updated>2008-04-08T17:01:30.316+03:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><title>Excecution time in Java</title><description>I am going to write my answer to the question " HOW DO I CALCULATE ELAPSED TIME IN JAVA ?"&lt;br /&gt;As far as I now there are two simple ways to calculate the elapsed time - excecution time in JAVA programming language.&lt;br /&gt;Java gives two methods ,nanoTime() and  currentTimeMillis() both declared in class java.lang.System .&lt;br /&gt;currentTimeMillis() returns the current time in milliseconds (long) and (as expected) nanoTime() returns the current value of the most precise available system timer in nanoseconds (long).&lt;br /&gt;Below you can see an example of how to calculate the excecution time of a method. The example bellow calculate excecution time of a simple method which it's just a for loop which print numbers from 0 to 1000 but it can be any method you want.&lt;br /&gt;&lt;br /&gt;First I used System.currentTimeMillis() to calculate the elapsed time and  then System.nanoTime().&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import java.lang.String;&lt;br /&gt;&lt;br /&gt;public class time_example {&lt;br /&gt; &lt;br /&gt;   public static void print_num(){&lt;br /&gt;      for(int i = 0 ; i&amp;lt;=1000 ; i++) {&lt;br /&gt; System.out.print(i+" ");&lt;br /&gt;      }&lt;br /&gt;      System.out.println();&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   public static void main(String args[]) {&lt;br /&gt;  &lt;br /&gt; long start,end;&lt;br /&gt; start = 0; end = 0;&lt;br /&gt;&lt;br /&gt; start = System.currentTimeMillis();&lt;br /&gt; print_num();&lt;br /&gt; end = System.currentTimeMillis();&lt;br /&gt;        System.out.println("Elapsed time (approximately) &lt;br /&gt;                   in milliseconds = " +(end-start));&lt;br /&gt;  &lt;br /&gt; start = System.nanoTime();&lt;br /&gt; print_num();&lt;br /&gt; end = System.nanoTime();&lt;br /&gt; System.out.println("Elapsed time (approximately)&lt;br /&gt;                   in nanoseconds = " +(end-start));&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And the output is :&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;0 1 2 3 4 5 ... 995 996 997 998 999 1000 &lt;br /&gt;Elapsed time (approximately) in milliseconds = 47&lt;br /&gt;0 1 2 3 4 5 ... 995 996 997 998 999 1000 &lt;br /&gt;Elapsed time (approximately) in nanoseconds = 193986945&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You may also want to see &lt;a href="http://akomaenablog.blogspot.com/2008/03/elapsed-time-in-c.html"&gt;Elapsed Time in C&lt;/a&gt;.&lt;br /&gt;I hope that this post was helpful and don't forget to post your comments. Thank you.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-6693892536814413";
/* 468x60,myfeed */
google_ad_slot = "7686098500";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;div align="center"&gt;
&lt;a href="http://akomaenablog.blogspot.com"&gt;&lt;img src="http://paperunits.googlepages.com/pc-blog.gif" 
alt="Another Computers Blog"/&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://akomaenablog.blogspot.com/2008/04/excecution-time-in-java.html</link><thr:total>0</thr:total><author>akoma1blog@yahoo.com (akoma1blog@yahoo.com)</author></item></channel></rss>