<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss1full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="http://aplawrence.com//rss/fullProgramming.rss">
<title>Programming Site News at A.P.Lawrence.com</title>
<link>http://aplawrence.com/</link>
<description>
Programming feed at aplawrence.com: Thousands of articles, reviews, consultants listings, skills tests, opinion, how-to's for Unix, Linux and Mac OS X, networking, web site maintenance and more.. 
</description>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>6</sy:updateFrequency>
<sy:updateBase>2008-01-01T00:00+00:00</sy:updateBase>
<dc:language>en</dc:language>
<dc:publisher>A.P. Lawrence</dc:publisher>
<dc:rights>Copyright  A.P. Lawrence</dc:rights>
<dc:creator>A.P. Lawrence (mailto:rssfeeds@aplawrence.com)</dc:creator>
<dc:date>2009-11-09T14:56:13+00:00</dc:date>
<image rdf:resource="http://aplawrence.com/image21.gif">
</image>
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://aplawrence.com/Girish/c-fileio.html" />
<rdf:li rdf:resource="http://aplawrence.com/Opinion/playing-god.html" />
<rdf:li rdf:resource="http://aplawrence.com/Web/more-grumbles.html" />
<rdf:li rdf:resource="http://aplawrence.com/Web/best-brightest.html" />
<rdf:li rdf:resource="http://aplawrence.com/Girish/vim-tips.html" />
<rdf:li rdf:resource="http://aplawrence.com/Girish/vim.html" />
<rdf:li rdf:resource="http://aplawrence.com/Unixart/C_is_for_Crap.html" />
<rdf:li rdf:resource="http://aplawrence.com/Girish/c-programming.html" />
</rdf:Seq>
</items>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ProgrammingSiteNewsAtAplawrencecom" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /></channel>
<image rdf:about="http://aplawrence.com/image21.gif">
<title>A.P.Lawrence Logo</title>
<url>http://aplawrence.com/image21.gif</url>
<link>http://aplawrence.com</link>
</image>


<item rdf:about="http://aplawrence.com/Girish/c-fileio.html">
<title>A simple file I/O program in C  by Girish Venkatachalam</title>
<description>Programming,Girish 

2009/10/19 by Girish Venkatachalam
&lt;br /&gt;
&lt;!-- LEFTADOK --&gt;
&lt;!-- PCOUNT --&gt;
&lt;!-- PCOUNT --&gt;

&lt;p&gt;&lt;i&gt;Girish Venkatachalam is a UNIX hacker with more than a decade of
networking and crypto programming experience.
His hobbies include yoga,cycling, cooking and he &lt;a href="http://gayatri-hitech.com/about.html"&gt;runs his own
business.&lt;/a&gt; Details here:&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href="http://gayatri-hitech.com"&gt;http://gayatri-hitech.com&lt;/a&gt;
&lt;br /&gt;&lt;a href="http://spam-cheetah.com"&gt;http://spam-cheetah.com&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Doing even the simplest programming tasks in C can be daunting due to
its fondness for segfaulting. A C program can be found crashing on
printf, command line parsing or nearly every attempt to print a string
that is NULL. Or even access it.
&lt;/p&gt;

&lt;p&gt;
Of course C can crash and behave nastily in many other ways too. That is
why you need hand holding when you are learning C programming.
&lt;/p&gt;

&lt;p&gt;
And one continues to learn C programming for many many  years. I have
dealt with this topic in my other articles in this very site. So please
refer to those articles for the facets of C that trips newbies.
&lt;/p&gt;

&lt;p&gt;
In any case I had to write this code sample as part of my work. I am
presently reverse engineering the MAPI protocol that MS Outlook speaks
to MS Exchange. My work does not so much involve reverse engineering
since Microsoft has published the entire MAPI protocol in full detail.
&lt;/p&gt;
&lt;p&gt;
So my work mostly involves implementing the specification. And there is
a project called OpenChange that has done the bulk of the work by riding
on top of Samba project. In spite of all this context and help, I still
find the project pretty daunting and challenging.
&lt;/p&gt;
&lt;p&gt;
As part of this work I had to read and write mail attachments. So I
thought I will write a simple C program and validate it before
integrating with the rest of the complex stuff.
&lt;/p&gt;

&lt;p&gt;
In so doing I felt that this sample might help a beginner C programmer
and even some experience hands since file I/O is such a common activity
and C is filled with various slips and dangers.
&lt;/p&gt;

&lt;p&gt;
I could have read the file size by reading the file header using the
stat(2) system call. But I chose this approach of read(2) returning
zero. Of course you could improve this program in many ways. But
this program is good in many ways though purists may object to some of
my practices.

&lt;/p&gt;

&lt;p&gt;
Using syslog() is a great way to debug and inform the user what is going
on. I want to switch over from using printf() to this as this can double
up as printf once you open the log with the LOG_PERROR flag.
&lt;/p&gt;

&lt;p&gt;
Once the development phase of the program is over you can remove this
flag and all logs go to the logfile alone. It is quite cool.
&lt;/p&gt;

&lt;p&gt;
Of course you can do pretty much everything this does using perl or any
other scripting language also. Please look at Sys::Syslog in perl.
&lt;/p&gt;

&lt;p&gt;
In case you are wondering, this program can read and write binary files
as well as text files. Shows the power and simplicity of C  programming
and in an oblique way also the genius/simplicity of UNIX itself.
&lt;/p&gt;

&lt;p&gt;
I will now leave the program to do the rest of the talking.
&lt;/p&gt;




&lt;font face="monospace"&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;stdlib.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;unistd.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;

&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;string.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;sys/types.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;sys/stat.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;fcntl.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;syslog.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;err.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;

&lt;font color="#8080ff"&gt;&lt;b&gt;#include &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;lt;errno.h&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Read and write binary/text from/to the file system &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;font color="#00ff00"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
readfile(&lt;font color="#00ff00"&gt;&lt;b&gt;char&lt;/b&gt;&lt;/font&gt; *f)&lt;br /&gt;
{&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ff00"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/font&gt; fd, c, bytes;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ff00"&gt;&lt;b&gt;char&lt;/b&gt;&lt;/font&gt; buf[&lt;font color="#ff40ff"&gt;&lt;b&gt;1024&lt;/b&gt;&lt;/font&gt;];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Open file for reading &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fd = open(f, O_RDONLY);&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(fd &amp;lt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  perror(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;File open for reading&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  exit(&lt;font color="#ff40ff"&gt;&lt;b&gt;128&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;do&lt;/b&gt;&lt;/font&gt; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  bytes =  read(fd, buf, &lt;font color="#ffff00"&gt;&lt;b&gt;sizeof&lt;/b&gt;&lt;/font&gt;(buf));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Once we are done reading then break &lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#00ffff"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   * out of the infinite loop.&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#00ffff"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(bytes == &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#ffff00"&gt;&lt;b&gt;break&lt;/b&gt;&lt;/font&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(bytes &amp;lt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  perror(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;read(2)&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  exit(&lt;font color="#ff40ff"&gt;&lt;b&gt;128&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  syslog(LOG_INFO, &lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;Read &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%d&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt; bytes from [&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;]&amp;quot;&lt;/b&gt;&lt;/font&gt;, bytes, f);&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Spit the file out on STDOUT &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  write(STDOUT_FILENO, buf, bytes);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;font color="#ffff00"&gt;&lt;b&gt;while&lt;/b&gt;&lt;/font&gt;(&lt;font color="#ff40ff"&gt;&lt;b&gt;1&lt;/b&gt;&lt;/font&gt;); &lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Infinite loop &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;syslog(LOG_INFO, &lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;Finished reading&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;font color="#00ff00"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
writefile(&lt;font color="#00ff00"&gt;&lt;b&gt;char&lt;/b&gt;&lt;/font&gt; *f)&lt;br /&gt;

{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ff00"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/font&gt; infd, outfd, c, inbytes, outbytes;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ff00"&gt;&lt;b&gt;char&lt;/b&gt;&lt;/font&gt; buf[&lt;font color="#ff40ff"&gt;&lt;b&gt;1024&lt;/b&gt;&lt;/font&gt;], outf[&lt;font color="#ff40ff"&gt;&lt;b&gt;1024&lt;/b&gt;&lt;/font&gt;];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;Please give output file to write to:&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;scanf(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;&lt;/b&gt;&lt;/font&gt;, outf);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Open file for reading &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;infd = open(f, O_RDONLY);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(infd &amp;lt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  perror(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;File open for reading&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  exit(&lt;font color="#ff40ff"&gt;&lt;b&gt;128&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Open file for writing &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;outfd = open(outf, O_CREAT | O_APPEND | O_WRONLY, S_IRWXU );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(outfd &amp;lt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  perror(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;File open for writing&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  exit(&lt;font color="#ff40ff"&gt;&lt;b&gt;128&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;syslog(LOG_INFO, &lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;File contents of &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;&lt;/b&gt;&lt;/font&gt;, f);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;do&lt;/b&gt;&lt;/font&gt; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  inbytes = read(infd, buf, &lt;font color="#ffff00"&gt;&lt;b&gt;sizeof&lt;/b&gt;&lt;/font&gt;(buf));&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Once we are done reading then break &lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#00ffff"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   * out of the infinite loop.&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color="#00ffff"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(inbytes == &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#ffff00"&gt;&lt;b&gt;break&lt;/b&gt;&lt;/font&gt;;&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(inbytes &amp;lt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  perror(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;read(2)&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  exit(&lt;font color="#ff40ff"&gt;&lt;b&gt;128&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  outbytes = write(outfd, buf, inbytes);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(outbytes &amp;lt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  perror(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;read(2)&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  exit(&lt;font color="#ff40ff"&gt;&lt;b&gt;128&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  syslog(LOG_INFO, &lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%d&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt; bytes read and &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%d&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt; written&amp;quot;&lt;/b&gt;&lt;/font&gt;, &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  inbytes, outbytes);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;font color="#ffff00"&gt;&lt;b&gt;while&lt;/b&gt;&lt;/font&gt;(&lt;font color="#ff40ff"&gt;&lt;b&gt;1&lt;/b&gt;&lt;/font&gt;); &lt;font color="#00ffff"&gt;&lt;b&gt;/*&lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt; Infinite loop &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;*/&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;

&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;syslog(LOG_INFO, &lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;Finished writing&amp;quot;&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/font&gt; &lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;font color="#00ff00"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/font&gt;&lt;br /&gt;
main(&lt;font color="#00ff00"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/font&gt; argc, &lt;font color="#00ff00"&gt;&lt;b&gt;char&lt;/b&gt;&lt;/font&gt; **argv)&lt;br /&gt;

{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ff00"&gt;&lt;b&gt;int&lt;/b&gt;&lt;/font&gt; fd;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ff00"&gt;&lt;b&gt;char&lt;/b&gt;&lt;/font&gt; *filename;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;openlog(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;fio&amp;quot;&lt;/b&gt;&lt;/font&gt;, LOG_PERROR | LOG_CONS | LOG_PID, LOG_USER);&lt;br /&gt;
&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(argc &amp;lt; &lt;font color="#ff40ff"&gt;&lt;b&gt;3&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  printf(&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot; &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt; usage: &lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt; &amp;lt;filename&amp;gt; r | w&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;\n&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;quot;&lt;/b&gt;&lt;/font&gt;, &lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  argv[&lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;], argv[&lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  exit(&lt;font color="#ff40ff"&gt;&lt;b&gt;128&lt;/b&gt;&lt;/font&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;(argv[&lt;font color="#ff40ff"&gt;&lt;b&gt;2&lt;/b&gt;&lt;/font&gt;][&lt;font color="#ff40ff"&gt;&lt;b&gt;0&lt;/b&gt;&lt;/font&gt;] == &lt;font color="#ff40ff"&gt;&lt;b&gt;&amp;#39;r&amp;#39;&lt;/b&gt;&lt;/font&gt;) {&lt;br /&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  readfile(argv[&lt;font color="#ff40ff"&gt;&lt;b&gt;1&lt;/b&gt;&lt;/font&gt;]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;font color="#ffff00"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  writefile(argv[&lt;font color="#ff40ff"&gt;&lt;b&gt;1&lt;/b&gt;&lt;/font&gt;]);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;/font&gt;

&lt;div style="text-align:center"&gt;&lt;a href="http://www.spam-cheetah.com/"&gt;&lt;img src="http://www.spam-cheetah.com/images/spam-cheetah.jpg" alt="running cheetah" /&gt;&lt;br /&gt; SpamCheetah&lt;br /&gt;Stop spam dead in its tracks!&lt;/a&gt;&lt;/div&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Girish/c-fileio.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wXzC9VYlLpK61e4xPok2LSVIpZc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wXzC9VYlLpK61e4xPok2LSVIpZc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wXzC9VYlLpK61e4xPok2LSVIpZc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wXzC9VYlLpK61e4xPok2LSVIpZc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Girish/c-fileio.html</link>
</item>
<item rdf:about="http://aplawrence.com/Opinion/playing-god.html">
<title>Playing god  </title>
<description>Opinion,Programming 

2009/10/11&lt;br /&gt;
&lt;!-- LEFTADOK --&gt;
&lt;!-- PCOUNT --&gt;
&lt;!-- PCOUNT --&gt;

&lt;p&gt;Some of you may have played "games" like Second Life.  If not, you probably know what it is.   I'd like you to imagine that it's a few hundred years from now and that I'm a computer game designer working on an advanced version of this game.&lt;/p&gt;
&lt;p&gt;Computers have changed a lot.   Storage is basically unlimited and processing power is beyond anything you could comprehend.  I finally have enough resources at my disposal that I can actually create sentience within the "game".  That is, I can populate it with creatures who can pass a Turing test, who apparently have "free will".   These pockets of sentience evolved from some of my original designs, and are pretty darn complicated, but of course I can still run any of it through a debugger if I want to.  I can also change the physics of their little Universe...&lt;/p&gt;
&lt;p&gt;In other words, I can "play god".&lt;/p&gt;
&lt;p&gt;Would I?  Would you?  I think I can answer that I definitely would not, though certainly there would be temptation.  But if I really thought that this computer generated world was very real to its software denizens, and really thought of them as sentient beings, how could I?  I might want to, I might even sometimes try to convince myself that interfering in some specific place might be more moral than 
remaining hands off, but I would hope that I would resist that temptation because it's all downhill from there.&lt;/p&gt;
&lt;p&gt;The atheists in the group have likely already guessed what comes next.   Some of those little programs (that's what they are, right?) have become religious.  They have imagined a "Creator" and are busily begging it for various actions and non-actions, any of which I could easily provide - if I wanted to "play god".&lt;/p&gt;
&lt;p&gt;How would you feel about those beseechers of favors great and small?  I'd feel sorry for them.   Sorry that they don't understand that it was all only a game.  Sorry that they weren't smart enough to see how the game works yet - and I'd wonder if they ever could be smart enough:   can a computer program realize that it is just a bit of code?&lt;/p&gt;
&lt;p&gt;I wouldn't play god.  If these little programs were as bent on self destruction as we seem to be, I don't think I could even watch.  I couldn't turn the game off - that would be immoral too.   I'd just let it run by itself and make a promise to myself to never create anything like that again.    I'd also warn everyone I knew that they shouldn't dabble with such games either.&lt;/p&gt;
&lt;p&gt;How about you?&lt;/p&gt;



&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Opinion/playing-god.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kCmujmlYS0PhRFpMnkxQvJamsJQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kCmujmlYS0PhRFpMnkxQvJamsJQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kCmujmlYS0PhRFpMnkxQvJamsJQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kCmujmlYS0PhRFpMnkxQvJamsJQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Opinion/playing-god.html</link>
</item>
<item rdf:about="http://aplawrence.com/Web/more-grumbles.html">
<title>More grumbling about lousy coding  </title>
<description>Web-HTML,Programming 

2009/10/11&lt;br /&gt;
&lt;!-- LEFTADOK --&gt;
&lt;!-- PCOUNT --&gt;
&lt;!-- PCOUNT --&gt;


&lt;p&gt;Just now I  tried to leave a comment at one of the sites in my RSS reader.  Initially, I was happy to see that it is one of those sites that try to let you authenticate with whatever you want:  Typepad, MovableType, OpenID, Facebook - pretty much anything.  Great, I thought, I'll use &lt;a href="http://aplawrence.com/Security/open_id.html"&gt;OpenID&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The authentication failed.   Wonderful - I tried Facebook.  That failed too.   One more time, how about Google Blogger?  Nope..&lt;/p&gt;
&lt;p&gt;Does anybody bother to TEST their code?  I *know* OpenID did what it is supposed to do - the problem is back with the PHP/Javascript  at the original site. That's where the disconnect is.&lt;/p&gt;
&lt;p&gt;Of course it's possible - all too possible - that  it's my fault for not using a Microsoft browser on a Microsoft operating system.    Let me just say this:  I don't want to leave a comment badly enough to start up VMware - especially as it might not be the actual issue.&lt;/p&gt;
&lt;p&gt;Arrgh.   Does the site have any "Contact" info so that I can at least notify them of this foolishness?  Of course not.   Nor would I expect that to help - they are plainly using a off-the-rack blogging system.   99% of the time the people using those things don't know a thing about what lies beneath.&lt;/p&gt;
&lt;p&gt;Sometimes I do pine for the days when a certain amount of computing competence was necessary to even get access to the vast Internet.   It would be a lot less vast Internet were that still the case, but then again conversations would be much more intelligent.&lt;/p&gt;
&lt;p&gt;Too much to ask for, so I can only close with "No comment".   Not because I didn't wish to comment, but because your software doesn't work.&lt;/p&gt;




&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Web/more-grumbles.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/V4k3SOf-UQ0H48mtTbnNZEjqTzw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/V4k3SOf-UQ0H48mtTbnNZEjqTzw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/V4k3SOf-UQ0H48mtTbnNZEjqTzw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/V4k3SOf-UQ0H48mtTbnNZEjqTzw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Web/more-grumbles.html</link>
</item>
<item rdf:about="http://aplawrence.com/Web/best-brightest.html">
<title>Only the best and the brightest? I call B.S., Google  </title>
<description>Web-HTML,Programming 

2009/10/08&lt;br /&gt;
&lt;!-- LEFTADOK --&gt;
&lt;!-- PCOUNT --&gt;
&lt;!-- PCOUNT --&gt;


&lt;p&gt;I recently read and reviewed &lt;a href="http://aplawrence.com/Books/googled.html"&gt;Googled: The End of the World As We Know It&lt;/a&gt;.  One of the 
things that stood out was Google's tough vetting process for engineers.  Supposedly only people at the top of their game need apply.&lt;/p&gt;
&lt;p&gt;  Google's current 
&lt;a href="http://www.google.com/intl/en/jobs/lifeatgoogle/englife.html"&gt;Jobs page for engineers&lt;/a&gt; confirms that, saying things like "Our search for the world's best engineers",  and that they want people who "Have broad knowledge and expertise" and "world-class programming skills ".  No slouches need apply.&lt;/p&gt;

 &lt;br clear="left" /&gt;
&lt;p&gt;I call B.S.&lt;/p&gt;
&lt;p&gt;Oh, don't misunderstand:  I'm a big fan.  I love Gmail, I'm eagerly looking 
forward to Google Wave and all that.  I'm no Google hater.&lt;/p&gt;
&lt;p&gt;But if Google has been hiring the best programmers in the world, 
they sure as heck aren't getting their money's worth.&lt;/p&gt;
&lt;p&gt;Let's just look at some recent examples.  I use Google Calendar.  I love 
it because I set it to remind me of things I need to do regularly, like dust or 
wash the floors.   Getting an email reminder makes these chores much harder 
to ignore than a "Honey-Do" list.&lt;/p&gt;
&lt;p&gt;Recently, those reminders just stopped.  Google's advice on public message 
boards where other people were complaining of the same thing?  Redo your reminders.&lt;/p&gt;
&lt;p&gt;Are they kidding?  Is reading an XML file to send reminders a difficult 
programming task? Is there any imaginable reason why this should just stop 
working AND need end-user intervention to correct?  I sure don't think so.&lt;/p&gt;
&lt;p&gt;How about Gmail?  Gosh, I love Gmail.  My wife likes it too, especially 
Labels.  Except suddenly she can't apply Labels directly.  She's not 
the only person with this problem; Google knows all about it, but doesn't 
yet know how to fix it.  Doesn't know how to fix it?  World class programmers 
don't know how to fix this?  Wow!&lt;/p&gt;
&lt;p&gt;Let's not forget that Gmail crashed hard recently and that there 
were rumors of cross-site scripting exploits back in April.  If true, 
that's not world-class either.&lt;/p&gt;
&lt;p&gt;And then we have my MacBook Pro sleep problem.  Like an overactive child, 
my MacBook doesn't want to go to sleep when I tell it to. 
The culprit is Google Toolbar in Firefox.  With that disabled, I can put my machine  to sleep quickly.  With it in place, no.  Now really, I can't imagine why a toolbar 
is so badly programmed that it should interfere with my putting my computer to bed, but there it is.  World class?  I think not.&lt;/p&gt;
&lt;p&gt;Or maybe this IS the best we can get.  Maybe programming still is so hellishly difficult that even the best and brightest are as befuddled and helpless as the rest of us.&lt;/p&gt;
&lt;p&gt;Isn't THAT a scary thought?&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Web/best-brightest.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/roPSuiiaw-acisfCWGBj7V94WU4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/roPSuiiaw-acisfCWGBj7V94WU4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/roPSuiiaw-acisfCWGBj7V94WU4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/roPSuiiaw-acisfCWGBj7V94WU4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Web/best-brightest.html</link>
</item>
<item rdf:about="http://aplawrence.com/Girish/vim-tips.html">
<title>Create syntax highlighted PDF and HTML files from C or perl  by Girish Venkatachalam</title>
<description>Programming,Girish,Shell,Linux 

2009/10/05 by  Girish Venkatachalam

&lt;br /&gt;
&lt;p&gt;&lt;i&gt;Girish Venkatachalam is a UNIX hacker with more than a decade of
networking and crypto programming experience.
His hobbies include yoga,cycling, cooking and he &lt;a href="http://gayatri-hitech.com/about.html"&gt;runs his own
business.&lt;/a&gt; Details here:&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href="http://gayatri-hitech.com"&gt;http://gayatri-hitech.com&lt;/a&gt;
&lt;br /&gt;&lt;a href="http://spam-cheetah.com"&gt;http://spam-cheetah.com&lt;/a&gt;
&lt;/p&gt;
&lt;!-- LEFTADOK --&gt;
&lt;!-- PCOUNT --&gt;
&lt;!-- PCOUNT --&gt;

&lt;p&gt;
People who have a necessity to publish source code for public view like
myself and Tony will benefit by this article.
&lt;/p&gt;
&lt;p&gt;
It is rather funny since I have published a lot of code in this very
site without syntax highlighting. Perhaps things will change with this
newfound wisdom.
&lt;/p&gt;
&lt;p&gt;
Let me quickly cut to the chase. This article comes close on the heels
of my &lt;a href="http://aplawrence.com/Girish/vim.html" target="_blank"&gt;Vim article&lt;/a&gt;
and you shall see in a moment why.
&lt;/p&gt;

&lt;p&gt;
Both my tips involve Vim and its genius is doing a perfect job of this.
Let us see for ourselves. We are going to use a C file sqlite2.c for
this purpose. 
&lt;/p&gt;
&lt;pre&gt;
$ vim sqlite2.c
:hardcopy &amp;gt; %.ps
&lt;/pre&gt;
&lt;p&gt;
gets us the file sqlite2.c.ps which is a postscript file. If you open it
with gv you find that it is neatly syntax highlighted. This will only
happen if you have it enabled in your vimrc like this:
&lt;/p&gt;
&lt;pre&gt;
sy on
se nu
se textwidth=72
se spell spelllang=en_us
noremap  :se nospell

&lt;/pre&gt;

&lt;p&gt;
Now that is an interesting vimrc. But let us focus on the first line
alone and get on with the article. The other way to do it is by opening
the file in vim and then highlighting the syntax manually with the
colon command &amp;quot;:sy on&amp;quot;.
&lt;/p&gt;
&lt;p&gt;
But we are not very happy with this for two reasons. It is in ps format
which is fine for academic papers and not for Internet publishing. And
the second problem with it is that it not suitable for batch
conversions. Hackers are incredibly lazy individuals who want the
computer to work for them. They don&amp;#39;t want to sit and do the job.
&lt;/p&gt;
&lt;p&gt;
What is the way out?
&lt;/p&gt;
&lt;p&gt;
It turns out that there are two ways. One way is interesting. The other
a bit boring but both work well.
&lt;/p&gt;
&lt;pre&gt;
$ vim -me -e -c &amp;quot;:hardcopy &amp;gt;%.ps&amp;quot; -c &amp;quot;:q&amp;quot; sqlite2.c

&lt;/pre&gt;
&lt;p&gt;
works but this is a better way.
&lt;/p&gt;
&lt;pre&gt;
$ vim -e -s sqlite2.c &amp;lt; hardcopy.vim

$ cat hardcopy.vim
:hardcopy &amp;gt; %.ps

&lt;/pre&gt;
&lt;p&gt;
It is obvious why we prefer the second approach. The first approach
takes a bunch of vim commands. You are limited to 10 and it is clumsy
since you start vim and kill it! 
&lt;/p&gt;
&lt;p&gt;
The second approach is filled with UNIX genius. It has redirection and
it is infinitely scalable since your one line vim script can do a lot
more than this job alone.
&lt;/p&gt;

&lt;p&gt;
Please spend an hour studying the tutorial for writing vim scripts by
typing this colon command &amp;quot;:help script&amp;quot;
&lt;/p&gt;
&lt;p&gt;
Vim scripting has object oriented programming, dictionaries arrays and
of course loops.
&lt;/p&gt;
&lt;p&gt;
But can&amp;#39;t we do this with the shell?
&lt;/p&gt;
&lt;pre&gt;
for file in &amp;quot;foo.c foo.perl bar.c script.sh&amp;quot;
do
	vim -e -s $file &amp;lt; process.vim
done

&lt;/pre&gt;
&lt;p&gt;
Good. Now there is one itch remaining. How to convert the resulting ps
file into PDF?
&lt;/p&gt;
&lt;pre&gt;
$ ps2pdf14 sqlite2.c.ps
$ xpdf sqlite2.c.pdf
&lt;/pre&gt;
&lt;p&gt;
Happy? No? Then I have another trick for you.
&lt;/p&gt;

&lt;p&gt;
Does looking at &lt;a href="http://aplawrence.com/Girish/sqlex.pdf" target="_blank"&gt;this PDF&lt;/a&gt; help?

&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;
There is a canned plugin that comes with Vim for html conversion. It is
called TOhtml. Invoke it inside a vim session with &amp;quot;:TOhtml&amp;quot;
&lt;/p&gt;
&lt;p&gt;
Now put two and two together and come up with your own way to convert C
files into syntax highlighted html.
&lt;/p&gt;
&lt;p&gt;
For those of you who hate white backgrounds there is a solution. You can
set this in vim.
&lt;/p&gt;
&lt;pre&gt;
:se background=dark
&lt;/pre&gt;
&lt;p&gt;
Happy?

&lt;/p&gt;

&lt;div style="text-align:center"&gt;&lt;a href="http://www.spam-cheetah.com/"&gt;&lt;img src="http://www.spam-cheetah.com/images/spam-cheetah.jpg" alt="running cheetah" /&gt;&lt;br /&gt; SpamCheetah&lt;br /&gt;Stop spam dead in its tracks!&lt;/a&gt;&lt;/div&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Girish/vim-tips.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6RViGwlpAD6QswHtGldx00S6VU4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6RViGwlpAD6QswHtGldx00S6VU4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6RViGwlpAD6QswHtGldx00S6VU4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6RViGwlpAD6QswHtGldx00S6VU4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Girish/vim-tips.html</link>
</item>
<item rdf:about="http://aplawrence.com/Girish/vim.html">
<title>Vim:; edit with vim  by Girish Venkatachalam</title>
<description>Programming,Girish,Shell,Linux 

2009/10/04 by Girish Venkatachalam


&lt;br /&gt;&lt;i&gt;Girish Venkatachalam is a UNIX hacker with more than a decade of
networking and crypto programming experience.
His hobbies include yoga,cycling, cooking and he &lt;a href="http://gayatri-hitech.com/about.html"&gt;runs his own
business.&lt;/a&gt; Details here:&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href="http://gayatri-hitech.com"&gt;http://gayatri-hitech.com&lt;/a&gt;
&lt;br /&gt;&lt;a href="http://spam-cheetah.com"&gt;http://spam-cheetah.com&lt;/a&gt;


&lt;br /&gt;&lt;br /&gt;
&lt;p&gt;
I type 
&lt;/p&gt;
&lt;pre&gt;
$ dict vim
 vim
       n 1: a healthy capacity for vigorous activity; &amp;quot;jogging works off
            my excess energy&amp;quot;; &amp;quot;he seemed full of vim and vigor&amp;quot;
            [syn: {energy}, {vitality}]
       2: an imaginative lively style (especially style of writing);
          &amp;quot;his writing conveys great energy&amp;quot; [syn: {energy}, {vigor},
           {vigour}]

&lt;/pre&gt;

&lt;!-- LEFTADOK --&gt;
&lt;p&gt;
and got this along with the idea that there is also an editor by name
Vim of course. It also goes on to tell me that Vim stands for 
&amp;quot;VI Improved&amp;quot;.
&lt;/p&gt;

&lt;p&gt;
For people who hate vi, vim does not offer much relief. They might end
up hating vim as well and sing paeans for emacs.
&lt;/p&gt;

&lt;p&gt;
Long ago I wrote an article claiming that I write my e-mails in Vim and
that led to a very interesting and sometimes annoying flame war in that
site. There seems to be a lot of passion that goes behind arguments for
deciding which editor is better: vi or emacs.
&lt;/p&gt;

&lt;p&gt;

I stopped using emacs a decade ago. I did use it though. When I was in
college. My fingers started aching though I use the keyboard a lot more
now than those days.
&lt;/p&gt;

&lt;p&gt;
The C-X C-C combinations and other combinations in emacs left my fingers
lusting for relief. But I used to think in those days that emacs must
have something in it to attract such fanfare.
&lt;/p&gt;

&lt;p&gt;
I do not recollect at what point I discontinued emacs but I know for
sure that I never used emacs in the last 10 years or so. Interestingly
not a single coding day would pass without my opening vi or vim.
&lt;/p&gt;

&lt;p&gt;
It was later that I realized that an editor is not used for coding
alone. An editor after all is necessary for every form of computer input
involving characters!
&lt;/p&gt;
&lt;p&gt;
My product SpamCheetah has a keyboard shortcuts facility which makes you
even navigate the feature rich web interface using keystrokes. Real
geeks do not use the mouse; they prefer the speed and convenience of
keyboards.
&lt;/p&gt;

&lt;p&gt;
And real geeks need real editors. They won&amp;#39;t sing paeans about a WYSIWIG
editor. They want a power editor. An editor that can serve as a friend,
philosopher and guide. They want an editor that can make them really
efficient, an editor that can automate mundane tasks. They want an
editor...sigh!
&lt;/p&gt;

&lt;p&gt;
It is too hard to meet the demands of geeks. So I better stop.
&lt;/p&gt;

&lt;p&gt;
In case you are wondering,I type this article in Vim. I create PDF files
in Vim using LaTeX, I code using vim, I write e-mails in Vim...I do
everything with vim using Vim. 
&lt;/p&gt;

&lt;p&gt;
Vim protects my fingers against wear and tear, vim highlights the syntax
for my C coding projects, config file editing moments and helps me
immensely when I learning new programming languages.
&lt;/p&gt;

&lt;p&gt;
The same editor also helps me identify spelling errors when I set&lt;/p&gt;
&lt;pre&gt;
:se spell spelllang=en_US
&lt;/pre&gt;
&lt;p&gt;and very interestingly it was vim that helped me create this most 
amazing page.

&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://spam-cheetah.com/cgi-bin/chanakya-quote.pl" target="_blank"&gt;Chanakya
quotes using fortune&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
I created a fortune file of Chanakya quotes from a web page by copy
pasting them into a vim buffer. I searched for digits and &amp;quot;.&amp;quot; and
removed them like this.&lt;/p&gt;

&lt;pre&gt;

:%s/[0-9]*//

:%s/\.//
&lt;/pre&gt;

&lt;p&gt;
Then I inserted the &amp;#39;%&amp;#39; character by this command:&lt;/p&gt;
&lt;pre&gt;
:%s/^$/%/g
&lt;/pre&gt;

&lt;p&gt;

The above line searches for blank lines identified by a beginning of the
line anchor &amp;#39;^&amp;#39; and end of the line anchor &amp;#39;$&amp;#39;.
&lt;/p&gt;
&lt;p&gt;
I then went on to create a fortune db using this command:&lt;/p&gt;
&lt;pre&gt;
$ strfile chanakya chanakya.dat
&lt;/pre&gt;
&lt;p&gt;
Then copying these two files into /usr/share/games/fortunes on my Debian
box was all that was necessary for this:&lt;/p&gt;
&lt;pre&gt;
$ fortune chanakya

&lt;/pre&gt;
&lt;p&gt;
I was happy with the result. But I had to fix certain inconsistencies
and fix problems. One nice thing I did was this:&lt;/p&gt;
&lt;pre&gt;
:%!fmt -w 60
&lt;/pre&gt;
&lt;p&gt;
This command formats the entire document to break at 60 columns without
breaking words of course.
&lt;/p&gt;
&lt;p&gt;
Then I wrote this CGI script:&lt;/p&gt;
&lt;pre&gt;

#!/usr/local/bin/perl -w
use CGI;

 $q = new CGI;
 print $q-&amp;gt;header,
 $q-&amp;gt;start_html(&amp;#39;Chanakya quotes [Press F5 for a new quote]&amp;#39;);

 $out = `/usr/games/fortune /spam-cheetah.com/cgi-bin/chanakya`;

 $q-&amp;gt;h1(&amp;#39;Chanakya quotes [F5 for a new quote]&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;quot;&amp;lt;em&amp;gt;&amp;quot;);
 $q-&amp;gt;print(&amp;#39;&amp;lt;pre&amp;gt;&amp;#39;);
 $q-&amp;gt;print($out);
 $q-&amp;gt;print(&amp;#39;&amp;lt;/pre&amp;gt;&amp;#39;);
 $q-&amp;gt;print(&amp;quot;&amp;lt;/em&amp;gt;&amp;quot;);
 $q-&amp;gt;end_html;


&lt;/pre&gt;
&lt;p&gt;
Such is the power of this fantastic editor. If you keep using it, your
efficiency increases by leaps and bounds. And after a long time you
become so acclimatized to the vim way of doing things that it comes
naturally to you.
&lt;/p&gt;
&lt;p&gt;
Vim also has an excellent help system. You can invoke help on any topic
with the &amp;quot;:help&amp;quot; command. It can also be navigated using the &amp;#39;C-]&amp;#39;
keystroke used with ctags. I cannot dwell too much upon it. Please see
 &lt;a href="http://linuxjournal.com/article/8289/" target="_blank"&gt;this article&lt;/a&gt; for
some details.
&lt;/p&gt;

&lt;p&gt;
In case you like the quotes you can download the fortune files from
here:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
	&lt;a href="http://gayatri-hitech.com/Misc/chanakya" target="_blank"&gt;chanakya&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
	&lt;a href="http://gayatri-hitech.com/Misc/chanakya.dat" target="_blank"&gt;chanakya.dat&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;

In case you are wondering who Chanakya is, he is one of the foremost
intellectuals who lived during the 350 BC time frame. Refer 
&lt;a href="http://en.wikipedia.org/wiki/Chanakya" target="_blank"&gt;wikipedia&lt;/a&gt;
for more details.
&lt;/p&gt;
&lt;p&gt;
He is the master of traditional Hindu wisdom and a manipulator and
diplomat beyond compare!
&lt;/p&gt;


&lt;div style="text-align:center"&gt;&lt;a href="http://www.spam-cheetah.com/"&gt;&lt;img src="http://www.spam-cheetah.com/images/spam-cheetah.jpg" alt="running cheetah" /&gt;&lt;br /&gt; SpamCheetah&lt;br /&gt;Stop spam dead in its tracks!&lt;/a&gt;&lt;/div&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Girish/vim.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CZ4_hBXf-PfU1LDxzvvfKgjrKls/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CZ4_hBXf-PfU1LDxzvvfKgjrKls/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CZ4_hBXf-PfU1LDxzvvfKgjrKls/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CZ4_hBXf-PfU1LDxzvvfKgjrKls/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Girish/vim.html</link>
</item>
<item rdf:about="http://aplawrence.com/Unixart/C_is_for_Crap.html">
<title>C is for Crap  by Andrew Smallshaw</title>
<description>Programming 

2009/09/30 by Andrew Smallshaw
&lt;br /&gt;
&lt;!-- LEFTADOK --&gt;
&lt;!-- PCOUNT --&gt;
&lt;!-- PCOUNT --&gt;
&lt;p&gt;&lt;i&gt;This is in response to &lt;a href="http://aplawrence.com/Girish/c-programming.html"&gt;The C programming language and its importance&lt;/a&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;I've seen many gushing uncritical treatises praising C to the hilt over the years.  They usually strike me as naive and this one is no exception.  This one at least avoids portraying C as all things to all people, but ultimately C is in many ways a backwards and primitive language. &lt;/p&gt;
&lt;p&gt;In some ways C was ahead of its time: removing I/O operations from the language proper and relegating them to library functions for instance.  It avoids C feeling too odd when you are writing a GUI or embedded app.  If you compare it to Fortran for instance, where these are language primitives, it is much more elegant - there are no actual keywords to be avoided in situations where they are not relevant.  &lt;/p&gt;
&lt;p&gt;However C still has many obvious flaws.  The curious operator precedence comes to mind straight away - there is only one sane way of parsing something like (a == b &amp;amp; c), but it is not the one C chooses. Syntactic limitations, such as the lack of a "then" keyword, were introduced for reasons that now seem laughable, but still remain making many simple typographical errors result in syntactically valid but incorrect code - if you have ever spent an hour wondering why "if (a == 1);" apparently behaves as a tautology, this is what caught you out.  It also lacks many facilities you would expect of a modern programming language.  &lt;/p&gt;
&lt;p&gt;For example, the lack of any form of exception handling is inexcusable in a modern language.  As a result you are constantly manually checking return values for fringe conditions, and then (in theory at least) passing those errors back up the program structure until such a time that hopefully you are able to handle them in a sane manner.  Often the logical structure of a program needs wholesale alteration simply to allow these error conditions to be propagated from one module to another.  This is a burden the C programmer should not have to face.&lt;/p&gt;
&lt;p&gt;However, the biggest problem has to be memory management, or more to the point, the almost complete lack thereof.  You can do pretty much whatever you want in C but you are doing it all yourself.  It shows itself up first and foremost in what are laughably termed strings - an operation that should be a simple function call turns into a lengthy sequence of operations, but before you even start you have to calculate how long the resulting string is going to be and allocate the space for it manually.  Of course, that in turn means you have to work out how to communicate a failure to allocate that memory to the rest of the program, not to mention determining when and where to conveniently free the space when you are done with it.  &lt;/p&gt;
&lt;p&gt;More complex data types can be even more problematic: a simple linked list soon becomes a no-brainer, and can be compacted down to a couple of sections of maybe half a dozen lines each, but the reason it becomes so straightforward is simply because you do it so frequently, for C has no built in list type.  When implementing more complex data structures, managing memory and the relationships between elements becomes exponentially more difficult than solving the actual problem at hand.  Using ML I can in an afternoon write a rich API implementing a sophisticated data structure, with multiple many-many relationships and shared elements between distinct data structures.  In C I will still be chasing NULL and dangling pointers, twiddling reference counters and praying I don't introduce memory leaks a fortnight later.  In practice this tends to mean that simplistic structures are chosen over more advanced ones: why do you think there are so many buffer overflow security vulnerabilities?&lt;/p&gt;
&lt;p&gt;Next we have C's supposed strengths.  The obvious one is that is can do things that no other language can.  This is demonstrably false.  Leaving aside the earlier-mentioned problem of feasibility - something may be possible but so fiendishly complex it is not economic - it is not true in any case.  When it comes to direct hardware hardware manipulation the supposed power of C (pointers) is hardly unique nor even the only way to solve the issue.  I am of the generation that grew up with the likes of the Sinclair Spectrum and Commodore 64 - we got quite used to PEEKing and POKEing our way through system memory even in interpreted Basic.  In any case how do you handle interrupts or program DMA transfers in C?  You use a library function to do it - there are no native capabilities.  This is hardly an approach inapplicable to other languages.&lt;/p&gt;
&lt;p&gt;C does benefit from the fact that its runtime support library is very compact.  It is true that this makes it appropriate for embedded and other low level systems.  However, this is not a property unique to C.  Forth and even some Basic dialects have similarly small footprints.  Or of course you can go for assembler with no overhead at all.  When memory gets really constrained even C's malloc() gets troublesome, since it inevitably leads to memory fragmentation and for this reason embedded systems often forgo its use entirely.  It may surprise you to learn that up until 10-15 years ago you didn't even have a malloc() available when Unix kernel programming, and I for one would argue that introducing it was a retrograde step.&lt;/p&gt;
&lt;p&gt;A real example of hardware access: consider Sun's OpenPROM system.  This is the equivalent of the BIOS you will find on Sun hardware, but it is a bit more advanced in that it also incorporates other capabilities such as programmability and proper diagnostic routines.  It was standardised and later picked up by Apple for its machines, which we will come to in a minute.  The bulk of the system is actually written in Forth.  Each add-on card also includes its own add-on drivers and diagnostics that integrate themselves into the system.  The drivers remain available and in use even after the operating system has booted if the OS lacks full native driver support for a piece of hardware.  The neat thing is that this works regardless of the CPU: it is executed by a tiny Forth interpreter and so it works on both 32 and 64 bit SPARC, and on Apple's PowerPC and x86 architectures.  Supposedly this is impossible in anything other than C, but you would be hard pressed to use it to do anything of the sort.&lt;/p&gt;
&lt;p&gt;Of course, all this is not to say C is completely without merit: one the contrary, it is still one of my preferred languages.  It is often described as a small language, but I dislike that characterisation: it is more mid-sized.  TCL or Scheme are true small languages: it does not benefit you at all since all that happens is that the complexity moves to the library.  At the other end of the scale you have the truly large languages such as C++ or ADA where the entire language is almost too big to keep in your head at once.  C is in the Goldilocks zone somewhere in the middle: the language is large and expressive enough to be useful without ever being daunting.&lt;/p&gt;
&lt;p&gt;However, the real strength of C is nothing to do with the virtues of the language per se at all.  That is its very ubiquity.  Almost any computer platform you care to mention is going to have at least one C implementation for it.  In addition, any third party libraries you may want to use are going to be either written in C or at least have C linkage, so if you want to simultaneously pull in libraries for database access, a network protocol, hardware control and still have full system call capabilities that is not a problem in C.  It it this position as the lingua franca of computer programming that is its single greatest single strength.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Unixart/C_is_for_Crap.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-LHFNeL6uwdfzbYzsGm12YKuwXI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-LHFNeL6uwdfzbYzsGm12YKuwXI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-LHFNeL6uwdfzbYzsGm12YKuwXI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-LHFNeL6uwdfzbYzsGm12YKuwXI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Unixart/C_is_for_Crap.html</link>
</item>
<item rdf:about="http://aplawrence.com/Girish/c-programming.html">
<title>The C programming language and its importance  by Girish Venkatachalam</title>
<description>Programming,Girish 

2009/09/27&lt;br /&gt;&lt;br /&gt;
Girish Venkatachalam

&lt;br /&gt;&lt;br /&gt;
&lt;!-- LEFTADOK --&gt;
&lt;!-- PCOUNT --&gt;
&lt;!-- PCOUNT --&gt;
&lt;p&gt;&lt;i&gt;Girish Venkatachalam is a UNIX hacker with more than a decade of
networking and crypto programming experience.
His hobbies include yoga,cycling, cooking and he &lt;a href="http://gayatri-hitech.com/about.html"&gt;runs his own
business.&lt;/a&gt; Details here:&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;

&lt;a href="http://gayatri-hitech.com"&gt;http://gayatri-hitech.com&lt;/a&gt;
&lt;br /&gt;&lt;a href="http://spam-cheetah.com"&gt;http://spam-cheetah.com&lt;/a&gt;
&lt;/p&gt;


&lt;p&gt;
I don&amp;#39;t like the title of this article. I know this is not appropriate
and I am not in a mood to look around or rack my brains for a fitting
title. It is going to be a tough proposition since words cannot
adequately express my feelings no matter what language I use.
&lt;/p&gt;

&lt;p&gt;
The depth of my feelings and conviction are so strong that no language
or communication medium can express my feelings in true glory. I can
perhaps sing a song about it, but I am no musician.
&lt;/p&gt;
&lt;p&gt;
So here we go. I shall try to explain the idea in this article. But I
hope you understand that this article can only capture the spirit and
not the details of my thought process.
&lt;/p&gt;

&lt;p&gt;
Even that is a good thing to achieve. The C programming language after
all is not for everybody. It is meant for people who need not be told
about it. It is meant for people who do not need to be taught.
&lt;/p&gt;
&lt;p&gt;
The C programming language is unique. It is special. It is small. It is
great and it is filled with UNIX genius. It is just like a typical UNIX
tool which does only one job, but does it well. The C language is small
but it is the most challenging programming skill to acquire today.
&lt;/p&gt;
&lt;p&gt;
I have been doing serious C programming for close to a decade now. But I
feel like a child on the seashore picking up a pebble here, a pebble
there when the vast ocean lies unexplored in front of me.
&lt;/p&gt;
&lt;p&gt;
This was stolen from Isaac Newton. And I also wish to steal another
saying of his. I have been able to do whatever programming I did using C
only due to the open source C programs I have seen in different projects
available in the familiar places like sourceforge and also in later days
the operating system source code under /usr/src in OpenBSD.
&lt;/p&gt;
&lt;p&gt;
Many people do not know that the BSD family of operating systems give
you the source code for everything that goes into the OS. With Linux,
there is fragmentation and there is no central repository. Anyway I
digress. So I was saying that the abundance of C programs I could read
and learn enabled me to say what Newton said.
&lt;/p&gt;
&lt;p&gt;
If I could see farther it is only by standing on the shoulders of 
giants gone before me.

&lt;/p&gt;
&lt;p&gt;
I taught C myself and learn the constructs and techniques, indentation
styles and so on looking at the wide cornucopia of programs available
for everyone to see.
&lt;/p&gt;
&lt;p&gt;
People foolishly think that copying, copy pasting and learning from
other people&amp;#39;s code is wrong. You have to do it yourself. How can you
get sillier than that?
&lt;/p&gt;
&lt;p&gt;
Don&amp;#39;t you know that the best way to learn is by example? And that you
should always learn from the masters? The best in the field?
&lt;/p&gt;
&lt;p&gt;
That being the case, you should browse C code. You should try to do
something on your own and compare what you have done with the masters.
That way you know where you stand and correct your thinking and coding
practices.
&lt;/p&gt;
&lt;p&gt;
C programming is not for everybody. I am sorry for sounding pompous but
that is simply the reality. It is not meant for individuals who are not
ready for the long haul. It is not meant for people who program with a
view towards making money or getting a job done.

&lt;/p&gt;
&lt;p&gt;
C is meant for people who understand the big picture well. It is meant
for technologists, technocrats and people who create and design stuff.
You have to go through the pains of C programming for at least 4 years
before you can call yourself an expert. If you choose to call yourself
that.
&lt;/p&gt;
&lt;p&gt;
I come across many C programmers who say that they will rate their C
skills as only 7 or 8 out of 10 even after programming for 5 years or
more.
&lt;/p&gt;
&lt;p&gt;
C is deep. C is painful, but it is fun since there is no comparison.
&lt;/p&gt;
&lt;p&gt;
Most of the time, what you can do in C, you cannot do in any other
language. Think of kernel programming or embedded systems.
&lt;/p&gt;
&lt;p&gt;
Also I wish to point out that the efforts in learning C and the big
picture are richly paid. No doubt about that. The deeper you go into
technology, you want to know about memory, CPU, registers and so on.
Embedded programming involves tight programming practices. You should be
careful with buffer sizes, with mallocs and so on. Your brain learns to
think like a genius once you do C programming for a while.
&lt;/p&gt;
 
&lt;div style="text-align:center"&gt;&lt;a href="http://www.spam-cheetah.com/"&gt;&lt;img src="http://www.spam-cheetah.com/images/spam-cheetah.jpg" alt="running cheetah" /&gt;&lt;br /&gt; SpamCheetah&lt;br /&gt;Stop spam dead in its tracks!&lt;/a&gt;&lt;/div&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Girish/c-programming.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;&lt;a href='http://www.mupromo.com/?ref=6872'&gt;Today's MacUpdate Promo, 40% off&lt;/a&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Tests"&gt;Skills Tests&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/psst.html"&gt;Psst - wanna work for yourself?&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;&lt;td&gt;&lt;a href="http://aplawrence.com/troubleshootingbook.html"&gt;Unix/Linux Troubleshooting e-book&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/rates.html"&gt;Consulting&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/advert.html"&gt;Advertise Here&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jBy2GnxeK61MVFL0tdVrqbSufcg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jBy2GnxeK61MVFL0tdVrqbSufcg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jBy2GnxeK61MVFL0tdVrqbSufcg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jBy2GnxeK61MVFL0tdVrqbSufcg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
<link>http://aplawrence.com/Girish/c-programming.html</link>
</item>
</rdf:RDF>
