<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8210127799629930349</id><updated>2011-11-27T16:34:17.681-08:00</updated><category term='Software'/><category term='Diary'/><category term='UNIX/Linux'/><category term='Japan'/><category term='C'/><title type='text'>unistd.cs</title><subtitle type='html'>Articles about Programming(C,Java,...) written by a Japanese university student majoring in Computer Science.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8210127799629930349.post-733105417579752142</id><published>2008-08-24T04:58:00.000-07:00</published><updated>2008-08-24T05:15:46.691-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software'/><title type='text'>Play Tetris with Emacs by "M-x tetris"</title><content type='html'>&lt;p&gt;You can play Tetris with Emacs by inputting command "M-x tetris". I played it and captured the movie. (env : Ubuntu-7.10-Desktop)&lt;/p&gt;
&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/nEchfz6lZNk&amp;hl=ja"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/nEchfz6lZNk&amp;hl=ja" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;
&lt;p&gt;&lt;b&gt;Original Text (Japanese)&lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://networkprogramming.blog18.fc2.com/blog-entry-52.html"&gt;http://networkprogramming.blog18.fc2.com/blog-entry-52.html&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8210127799629930349-733105417579752142?l=unistd-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/733105417579752142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8210127799629930349&amp;postID=733105417579752142' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/733105417579752142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/733105417579752142'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/2008/08/play-tetris-with-emacs-by-m-x-tetris.html' title='Play Tetris with Emacs by &quot;M-x tetris&quot;'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8210127799629930349.post-6723160276940918985</id><published>2008-08-15T05:57:00.000-07:00</published><updated>2008-08-15T07:12:38.255-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Japan'/><title type='text'>Serious Shortage of PG and SE in Japan</title><content type='html'>&lt;p&gt;Programmers and System Engineers are shortage in Japan. It is because they are treated badly. Do you know 3K? 3K are &lt;i&gt;Kitsui&lt;/i&gt;(hard), &lt;i&gt;Kaerenai&lt;/i&gt;(can't come home because of the work is very busy) and &lt;i&gt;Kyuryo ga yasui&lt;/i&gt;(bad pay).&lt;/p&gt;

&lt;p&gt;Recently, we hear 7K! 7K is old 3K + new 4K. &lt;i&gt;Kisoku ga kibishi&lt;/i&gt;(strict rule), &lt;i&gt;Kyuka ga torenai&lt;/i&gt;(take no leave of absence), &lt;i&gt;Kesyo ga noranai&lt;/i&gt;(make-up isn't on a roll because of skin roughness caused by tiredness) and &lt;i&gt;Kekkon dekinai&lt;/i&gt;(can't marry because of no encounter to the opposite sex and busyness).&lt;/p&gt;

&lt;p&gt;Therefore, even university students who majors in computer science are unwilling to be PG or SE. So, the companies employ not only science students (who don't major in computer science) but also liberal arts students!&lt;/p&gt;

&lt;p&gt;A professor said we(university students who majors in CS) should enter "&lt;i&gt;Matomona&lt;/i&gt;" companies which treat us as software engineers. For example, Google, Microsoft, Sun Microsystems, ... They are all foreign affiliated company^^; In other words, many Japanese company aren't &lt;i&gt;"Matomo"&lt;/i&gt; and treat us as a cogwheel of the company.&lt;/p&gt;

&lt;p&gt;I think IT companies have no future in Japan if nothing is done.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8210127799629930349-6723160276940918985?l=unistd-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/6723160276940918985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8210127799629930349&amp;postID=6723160276940918985' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/6723160276940918985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/6723160276940918985'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/2008/08/serious-shortage-of-pg-and-se-in-japan.html' title='Serious Shortage of PG and SE in Japan'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8210127799629930349.post-3337619769095378610</id><published>2008-08-13T18:52:00.000-07:00</published><updated>2008-08-13T19:57:15.454-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='UNIX/Linux'/><title type='text'>Cannot Compile C Programs in Initial Ubuntu</title><content type='html'>&lt;p&gt;Ubuntu is very useful and one of Linux distribution I recommend for Linux beginner.&lt;/p&gt;

&lt;p&gt;However, we can't compile C programs by gcc even "Hello, world!" because of not installed C developer's libraries. I think that it is a hole many beginners developing in Ubuntu fall into.&lt;/p&gt;

&lt;p&gt;Therefore, I wrote how to install C developer's libraries "libc-dev" and editor "Emacs" in Ubuntu.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debian Packages&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Because Debian packages is available in Ubuntu, We can install many software by "apt-get" command. However, Ubuntu doesn't the administrator's account "root" from consideration on security. Therefore, we use "sudo" command instead of "su" command in order to run commands need administrative privilege. That is, we generally use "sudo" command to install a package. &lt;i&gt;package&lt;/i&gt; means the package's name you install.&lt;/p&gt;

&lt;pre class="code"&gt;
$ sudo apt-get install &lt;i&gt;package&lt;/i&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Developer's library in C: libc6-dev&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Run the following command in a terminal(shell). Answer "y" to questions during install.&lt;/p&gt;
&lt;pre class="code"&gt;
$ sudo apt-get install libc6-dev
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Editor: emacs&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="out"&gt;
$ sudo apt-get install emacs
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Original Text(Japanese)&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://networkprogramming.blog18.fc2.com/blog-entry-62.html"&gt;http://networkprogramming.blog18.fc2.com/blog-entry-62.html&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8210127799629930349-3337619769095378610?l=unistd-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/3337619769095378610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8210127799629930349&amp;postID=3337619769095378610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/3337619769095378610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/3337619769095378610'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/2008/08/cannot-compile-c-programs-in-initial.html' title='Cannot Compile C Programs in Initial Ubuntu'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8210127799629930349.post-436376939078116056</id><published>2008-08-11T19:52:00.001-07:00</published><updated>2008-08-15T07:14:40.849-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Diary'/><category scheme='http://www.blogger.com/atom/ns#' term='Japan'/><title type='text'>Review: National Museum of Emerging Science and Innovation</title><content type='html'>&lt;p&gt;I went to &lt;a href="http://www.miraikan.jst.go.jp/index_e.html" target="_blank"&gt;&lt;i&gt;Miraikan&lt;/i&gt;&lt;/a&gt; (National Museum of Emerging Science and Innovation) in Odaiba in Japan. Its Curator is Japanese 2nd astronaut Mr.Mouri! I saw the permanent exhibit which has 4 fields: 1.Innovation and the Future, 2.Information Science and Technology for Society, 3.Life Science, and 4.The Earth Environment and Frontiers. I major in Computer Science, so I was looking forward to look at the 1st and 2nd areas.&lt;/p&gt;

&lt;p&gt;1. &lt;strong&gt;Innovation and the Future&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This sector shows micro machines, robots, condensed matter physics(superconductivity, electromagnetic induction), and so on.&lt;/p&gt;
&lt;p&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_h08EWItDTZo/SKEE_SWhjvI/AAAAAAAAAAM/MQnsPhdfY2Y/s320/acceleration_sensor.jpg" border="0" alt="Acceleration Sensor Module" id="BLOGGER_PHOTO_ID_5233469727285808882" /&gt;Japanese game "&lt;a href="http://www.amazon.com/exec/obidos/ASIN/B00005AYE5/unistdcs-20/ref=nosim/" target="_blank"&gt;Kirby Tilt N' Tumble&lt;/a&gt;" is displayed as an example of using acceleration sensor. Recently, &lt;a href="http://www.amazon.com/exec/obidos/ASIN/B000IMWK2G/unistdcs-20/ref=nosim/" target="_blank"&gt;Nintendo Wii Remote Controller&lt;/a&gt; uses this device. This picture is an acceleration sensor of mine. We can buy such a module at a low price in Akihabara in Japan.&lt;/p&gt;
&lt;p&gt;A midget model of linear motor car: well-known application of superconductivity is there. The midget runs very slowly but it is truly a linear motor car. An interpreter taught the mechanism to a family.&lt;/p&gt;
&lt;p&gt;There are some robots which can control by children. I saw a children operating a robot and fetching a block by robot's arms. He looks very joyful!&lt;/p&gt;

&lt;p&gt;2. &lt;strong&gt;Information Science and Technology for Society&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There is a high-profile model in this area. It is a model of the Internet. It is constructed of the models of nodes, packets, lines, and routers. It seems to show the packet routing.&lt;/p&gt;
&lt;p&gt;Another topic of this area is the interface between humans and computers. We can see and use optical interfaces, speech recognition devices and so on.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8210127799629930349-436376939078116056?l=unistd-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/436376939078116056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8210127799629930349&amp;postID=436376939078116056' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/436376939078116056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/436376939078116056'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/2008/08/review-national-museum-of-emerging.html' title='Review: National Museum of Emerging Science and Innovation'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_h08EWItDTZo/SKEE_SWhjvI/AAAAAAAAAAM/MQnsPhdfY2Y/s72-c/acceleration_sensor.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8210127799629930349.post-5470475161408987207</id><published>2008-08-11T05:35:00.000-07:00</published><updated>2008-08-11T06:24:16.212-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software'/><title type='text'>Only 12 Commands for Emacs Beginners</title><content type='html'>&lt;p&gt;Emacs has very many commands, so beginners are apt to dislike Emacs. I also did.&lt;/p&gt;
&lt;p&gt;However, I learned a few commands of Emacs someday. Then I became to use Emacs so-so and to enjoy Emacs! By learning the least commands, I became able to use emacs! Since then, Emacs is one of my favorite editors.&lt;/p&gt;
&lt;p&gt;Therefore, I listed up only 12 commands for Emacs beginners.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Notation&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C-x : to type "Ctrl" key and "x" key at the same time.&lt;/li&gt;
&lt;li&gt;M-x : to type "Meta"("Alt") key and "x" key at the same time.&lt;/li&gt;
&lt;li&gt;C-x C-y : to type C-x, then type C-y.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Launch Emacs&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Normal :&lt;br&gt;
&gt; emacs &lt;i&gt;filename&lt;/i&gt;&lt;br&gt;
Other Window :&lt;br&gt;
&gt; emacs &lt;i&gt;filename&lt;/i&gt; &amp;&lt;br&gt;
in Current Shell (&amp;lt;- Useful!) :&lt;br&gt;
&gt; emacs &lt;i&gt;filename&lt;/i&gt; -nw&lt;/p&gt;

&lt;p&gt;&lt;b&gt;File&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C-x C-f : Open File&lt;/li&gt;
&lt;li&gt;C-x C-s : Save File&lt;/li&gt;
&lt;li&gt;C-x C-c : Save File and Exit Emacs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Edit&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C-@ : Set Mark&lt;/li&gt;
&lt;li&gt;C-w : Cut (from Mark to Cursor)&lt;/li&gt;
&lt;li&gt;M-w : Copy (from Mark to Cursor)&lt;/li&gt;
&lt;li&gt;C-y : Paste&lt;/li&gt;
&lt;li&gt;C-_ : Undo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Other&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C-z : Interrupt (Return to Shell)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you launched Emacs in a Shell(emacs &lt;i&gt;filename&lt;/i&gt; -nw), it is useful to return the Shell by this and to restart the Emacs by "fg" command.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Original Text(Japanese)&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://networkprogramming.blog18.fc2.com/blog-entry-59.html" target="_blank"&gt;http://networkprogramming.blog18.fc2.com/blog-entry-59.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8210127799629930349-5470475161408987207?l=unistd-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/5470475161408987207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8210127799629930349&amp;postID=5470475161408987207' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/5470475161408987207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/5470475161408987207'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/2008/08/only-12-commands-for-emacs-beginners.html' title='Only 12 Commands for Emacs Beginners'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8210127799629930349.post-5225241599375017868</id><published>2008-08-09T20:14:00.000-07:00</published><updated>2008-08-09T23:02:16.195-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><title type='text'>Compute Determinant of 3x3-Matrix with Sarrus' Method</title><content type='html'>&lt;p&gt;I wrote a program which computes determinant of 3x3-matrix with Sarrus' Method because someone accessed my blog in order to find a program computing determinant of 3x3-matrix. This program is written in C.&lt;/p&gt;

&lt;p&gt;Of course, we can calculate it by Cofactor Expansion, but Sarrus' Method is much easier than it. So, I use Sarrus' Method.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Function to Compute Determinant of Matrix&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;
int det(int a[3][3]) {
  return a[0][0]*a[1][1]*a[2][2]
       + a[0][1]*a[1][2]*a[2][0]
       + a[0][2]*a[1][0]*a[2][1]
       - a[0][2]*a[1][1]*a[2][0]
       - a[1][2]*a[2][1]*a[0][0]
       - a[2][2]*a[0][1]*a[1][0];
}
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Main Function for Test&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

int main(int argc, char *argv[]) {
  int a[3][3], i, j;

  if(argc == 1) {
    a[0][0] = 1; a[0][1] = 2; a[0][2] = 3;
    a[1][0] = 4; a[1][1] = 5; a[1][2] = 6;
    a[2][0] = 7; a[2][1] = 8; a[2][2] = 9;
  } else if(argc == 10) {
    for(i=0; i&amp;lt;3; i++)
      for(j=0; j&amp;lt;3; j++)
 a[i][j] = atoi(argv[3*i+j+1]);
  } else {
    printf("Usage:\n");
    printf("./a.out\n");
    printf("   or\n");
    printf("./a.out a11 a12 a13 a21 a22 a23 a31 a32 a33");
  }

  printf("a =\n");
  for(i=0; i&amp;lt;3; i++) {
    for(j=0; j&amp;lt;3; j++) {
      printf("%3d", a[i][j]);
    }
    printf("\n");
  }
  printf("\n");

  printf("det(a) = %d\n", det(a));

  return 0;
}
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Output&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;
$ ./det
a =
  1  2  3
  4  5  6
  7  8  9

det(a) = 0
&lt;/pre&gt;

&lt;pre&gt;
$ ./det 1 6 -2 5 -3 4 -1 -2 4
a =
  1  6 -2
  5 -3  4
 -1 -2  4

det(a) = -122
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Main Function for Test(Simple Version)&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;I prepare simple version of test function for beginners of programming.&lt;/p&gt;

&lt;pre&gt;
#include &amp;lt;stdio.h&amp;gt;

int main(int argc, char *argv[]) {
  int a[3][3];

  a[0][0] = 1; a[0][1] = 2; a[0][2] = 3;
  a[1][0] = 4; a[1][1] = 5; a[1][2] = 6;
  a[2][0] = 7; a[2][1] = 8; a[2][2] = 9;

  printf("det(a) = %d\n", det(a));

  return 0;
}
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Original Text(Japanese)&lt;/b&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://networkprogramming.blog18.fc2.com/blog-entry-63.html" target="_blank"&gt;http://networkprogramming.blog18.fc2.com/blog-entry-63.html&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8210127799629930349-5225241599375017868?l=unistd-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/5225241599375017868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8210127799629930349&amp;postID=5225241599375017868' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/5225241599375017868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/5225241599375017868'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/2008/08/compute-determinant-of-3x3-matrix-with.html' title='Compute Determinant of 3x3-Matrix with Sarrus&apos; Method'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8210127799629930349.post-3420173196380134234</id><published>2008-08-09T07:50:00.000-07:00</published><updated>2008-08-13T19:58:02.428-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='UNIX/Linux'/><title type='text'>Implement Simple Shell - UNIX System Programming</title><content type='html'>I implemented a simple shell in programming language C with UNIX system calls. Now it has only following functions, but I will add some functions(Redirection, Pipe, Background running, ...) in future.
&lt;ol&gt;&lt;li&gt;Run inputed commands.&lt;/li&gt;&lt;li&gt;"exit" command.&lt;/li&gt;&lt;/ol&gt;

&lt;b&gt;Code&lt;/b&gt;
&lt;pre&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;sys/wait.h&amp;gt;
#include &amp;lt;sys/types.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;

#define MAX_ARGS 10
#define MAX_LEN  100

void child(int argc, char *argv[MAX_ARGS]);

int main()
{
  int argc, n = 0;
  int status;
  char input[MAX_LEN], *argv[MAX_ARGS], *cp;
  const char *delim = " \t\n"; /* delimiters of commands */

  while (1) {
    /* show a prompt */
    ++n;
    printf("command[%d] ", n); 

    /* read a line */
    if (fgets(input, sizeof(input), stdin) == NULL) {
      /* inputed EOF(Ctrl-D) */
      printf("Goodbye!\n");
      exit(0);
    }

    /* split the input to commands with blank and Tab */
    cp = input;
    for (argc = 0; argc &amp;lt; MAX_ARGS; argc++) {
      if ((argv[argc] = strtok(cp,delim)) == NULL)
        break;
      cp = NULL;
    }
    /* exit this shell when "exit" is inputed */
    if(strcmp(argv[0], "exit") == 0) {
      printf("Goodbye!\n");
      exit(0);
    }
    pid_t pid = fork();
    if(pid == -1) {
 /* failed to fork() */
      perror("fork");
      exit(1);
    } else if(pid == 0) {
 /* child process */
      child(argc, argv);
    } else {
 /* parent process */
      wait(&amp;status);
    }
  }
}

void child(int argc, char *argv[MAX_ARGS]) {
  execvp(argv[0], argv);
}
&lt;/pre&gt;

&lt;b&gt;Result&lt;/b&gt;
&lt;pre class="out"&gt;
****@ubuntu-vm:~/work/os$ gcc -Wall s_shell.c
****@ubuntu-vm:~/work/os$ ./a.out
command[1] ls
#ex01.c#  execlp0.c   fileio1.c~  fileio4.c~  s_shell.c
a.out     execve0.c   fileio2.c   foo         system0.c
ex1.c     execve0.c~  fileio2.c~  fork0.c     wait0.c
ex1.c~    fileio0.c   fileio3.c   fork0.c~    wait0.c~
ex2.c     fileio0.c~  fileio3.c~  hello.c
ex2.c~    fileio1.c   fileio4.c   httpget.c
command[2] cat hello.c
#include &amp;lt;stdio.h&amp;gt;
int main() {
  printf("hello, world!\n");
  return 0;
}
command[3] gcc -Wall hello.c
command[4] ./a.out
hello, world!
command[5] exit
Goodbye!
****@ubuntu-vm:~/work/os$ 
&lt;/pre&gt;

&lt;b&gt;Reference site&lt;/b&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://sato-www.cs.titech.ac.jp/pro3/" target="_blank"&gt;http://sato-www.cs.titech.ac.jp/pro3/&lt;/a&gt;(Tokyo Institute of Technology)&lt;/li&gt;&lt;/ul&gt;

&lt;b&gt;Original Text(Japanese)&lt;/b&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="http://networkprogramming.blog18.fc2.com/blog-entry-22.html" target="_blank"&gt;http://networkprogramming.blog18.fc2.com/blog-entry-22.html&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8210127799629930349-3420173196380134234?l=unistd-cs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://unistd-cs.blogspot.com/feeds/3420173196380134234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8210127799629930349&amp;postID=3420173196380134234' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/3420173196380134234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8210127799629930349/posts/default/3420173196380134234'/><link rel='alternate' type='text/html' href='http://unistd-cs.blogspot.com/2008/08/implement-simple-shell-unix-system.html' title='Implement Simple Shell - UNIX System Programming'/><author><name>TBVector</name><uri>http://www.blogger.com/profile/04124645267323218952</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
