<?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:blogger='http://schemas.google.com/blogger/2008' 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-6097164267918317497</id><updated>2024-10-03T11:46:33.973-07:00</updated><category term="C Programming"/><category term="C Programming Tutorial"/><title type='text'>Programming Tutorial</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-6230236580089195075</id><published>2011-11-11T07:47:00.000-08:00</published><updated>2011-11-11T07:47:34.772-08:00</updated><title type='text'>Kerala University Btech First &amp; Second Semester Exam result 2011</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;Kerala University btech Combined 1st &amp;amp; 2nd Semester 2011 Exam Result will Published on 14-11-2011.&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;To view results go to&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://www.keralauniversity.edu/&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;http://www.keralauniversity.edu/&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/6230236580089195075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/11/kerala-university-btech-first-second.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/6230236580089195075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/6230236580089195075'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/11/kerala-university-btech-first-second.html' title='Kerala University Btech First &amp; Second Semester Exam result 2011'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-4462455856275751549</id><published>2011-11-03T06:18:00.000-07:00</published><updated>2011-11-03T06:19:58.642-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming Tutorial"/><title type='text'>File Handling in C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;We frequently use files for storing information which can be processed by our programs. In order to store information permanently and retrieve it&amp;nbsp; we need to use files.&lt;/div&gt;&lt;h2 style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Files are not only used for data. Our programs are also stored in files.&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The editor which you use to enter your program and save it, simply manipulates files for you. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The Unix commands &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;cat, cp, cmp &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;are all programs which process your files.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;In order to use files we have to learn about &lt;b&gt;&lt;i&gt;File I/O&lt;/i&gt;&lt;/b&gt; i.e. how to write information to a file and how to read information from a file. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;We will see that file I/O is almost identical to the terminal I/O that we have being using so far. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The primary difference between manipulating files and doing terminal I/O is that we must specify in our programs which files we wish to use. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;As you know, you can have many files on your disk. If you wish to use a file in your programs, then you must specify which file or files you wish to use.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Specifying the file you wish to use is referred to as &lt;b&gt;&lt;i&gt;opening&lt;/i&gt;&lt;/b&gt; the file. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;When you open a file you must also specify what you wish to do with it i.e. &lt;b&gt;Read&lt;/b&gt; from the file, &lt;b&gt;Write&lt;/b&gt; to the file, or both. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Because you may use a number of different files in your program, you must specify when reading or writing which file you wish to use. This is accomplished by using a variable called a&lt;b&gt; file pointer.&lt;/b&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Every file you open has its own file pointer variable. When you wish to write to a file you specify the file by using its file pointer variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;You declare these file pointer variables as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;FILE&amp;nbsp; *fopen(), *fp1, *fp2, *fp3; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The variables &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp1, fp2, fp3 &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;are file pointers. You may use any name you wish. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The file &amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;stdio.h&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; contains declarations for the Standard I/O library and should always be &lt;b&gt;include&lt;/b&gt;d at the very beginning of C programs using files. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Constants such as &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;FILE, EOF&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; and &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;NULL &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;are defined in &amp;lt;&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;stdio.h&amp;gt;&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;You should note that a file pointer is simply a variable like an integer or character. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;It does &lt;b&gt;not&lt;/b&gt; &lt;i&gt;point&lt;/i&gt; to a file or the data in a file. It is simply used to indicate which file your I/O operation refers to. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;A file number is used in the Basic language and a unit number is used in Fortran for the same purpose.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The function &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fopen&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;is one of the Standard Library functions and returns a file pointer which you use&amp;nbsp; to refer to the file you have opened e.g.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;NO-BOK&quot; style=&quot;font-family: Courier;&quot;&gt;fp = fopen( “prog.c”,&amp;nbsp; “r”) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The above statement &lt;b&gt;opens&lt;/b&gt; a file called &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.c&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; for &lt;b&gt;reading&lt;/b&gt; and associates the file pointer &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; with the file. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;When we wish to access this file for I/O, we use the file pointer variable &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; to refer to it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;You can have up to about 20 files open in your program - you need one file pointer for each file you intend to use. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Times;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;&lt;/b&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;File I/O&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoBodyText&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoBodyText&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The Standard I/O Library provides similar routines for file I/O to those used &amp;nbsp;for standard I/O. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The routine &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;getc(fp) &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;is similar to &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;getchar() &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;and &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;putc(c,fp)&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is similar to &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;putchar(c).&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Thus the statement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; c = getc(fp); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;reads the next character from the file referenced by &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; and the statement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; putc(c,fp); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;writes the character &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;c&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; into file referenced by &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp.&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* file.c: Display contents of a file on screen */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;void main() &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; FILE *fopen(), *fp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; int c ; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;NO-BOK&quot; style=&quot;font-family: Courier;&quot;&gt;fp = fopen( “prog.c”, “r” ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;NO-BOK&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;c = getc( fp ) ; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; while (&amp;nbsp; c != EOF ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar( c ); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc ( fp );  &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; fclose( fp ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;In this program, we open the file &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.c &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;for reading. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;We then read a character from the file. This file must exist for this program to work. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;If the file is empty, we are at the end, so &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;getc&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; returns &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;EOF&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; a special value to indicate that the end of file has been reached. (Normally -1 is used for &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;EOF&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The while loop simply keeps reading characters from the file and displaying them, until the end of the file is reached.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The function &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fclose&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;is used to &lt;b&gt;&lt;i&gt;close&lt;/i&gt;&lt;/b&gt; the file i.e. indicate that we are finished processing this file. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;We could reuse the file pointer &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; by opening another file. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;This program is in effect a special purpose &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;cat &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;command. It displays file contents on the screen, but &lt;b&gt;only&lt;/b&gt; for a file called &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.c&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;By allowing the user enter a file name, which would be stored in a string, we can modify the above to make it an &lt;b&gt;interactive&lt;/b&gt; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;cat &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;command:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* cat2.c: Prompt user for filename and display file on screen */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;void main() &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; FILE *fopen(), *fp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; int c ; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; char filename[40] ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; printf(“Enter file to be displayed: “);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; gets( filename ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; fp = fopen( filename, “r”);&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; c = getc( fp ) ; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; while (&amp;nbsp; c != EOF ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar(c); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc ( fp );  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; fclose( fp ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;In this program, we pass the name of the file to be opened which is stored in the array called &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;filename&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;, to the &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fopen&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; function. In general, anywhere a string constant such as &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;“prog,c”&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; can be used so can a character array such as &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;filename&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;. (Note the &lt;b&gt;reverse&lt;/b&gt; is &lt;b&gt;not&lt;/b&gt; true).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The above programs suffer a major limitation. They &lt;b&gt;do not&lt;/b&gt; check whether the files to be used exist or not. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;If you attempt to read from an non-existent file, your program will crash!!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fopen&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; function was designed to cope with this eventuality. It checks if the file can be opened appropriately. If the file &lt;b&gt;cannot be opened&lt;/b&gt;, it returns a &lt;b&gt;NULL&lt;/b&gt; pointer. Thus by checking the file pointer returned by &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fopen&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;, you can determine if the file was opened correctly and take appropriate action e.g.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp = fopen (filename, “r”) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( fp&amp;nbsp; ==&amp;nbsp; NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for reading \n”, filename );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1) ; /*Terminate program: Commit suicide !!*/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The above code fragment show how a program might check if a file could be opened appropriately.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The function &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;exit()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is a special function which terminates your program immediately. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;exit(0) mean that you wish to indicate that your program terminated successfully whereas a nonzero value means that your program is terminating due to an error condition.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Alternatively, you could prompt the user to enter the filename again, and try to open it again:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp = fopen (fname, “r”) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( fp&amp;nbsp; ==&amp;nbsp; NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for reading \n”, fname );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“\n\nEnter filename :” );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gets( fname );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp = fopen (fname, “r”) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;In this code fragment, we keep reading filenames from the user until a valid existing filename is entered.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Exercise&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Modify the above code fragment to allow the user 3 chances to enter a valid filename. If a valid file name is not entered after 3 chances, terminate the program.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;RULE: Always check when opening files, that fopen succeeds in opening the files appropriately.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Obeying this simple rule will save you much headache.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Example 1&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;: Write a program to count the number of lines and characters in a file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;: Each line of input from a file or keyboard will be terminated by the newline character &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;‘\n’&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;. Thus by counting newlines we know how many lines there are in our input.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/*count.c : Count characters in a file*/ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;void main() &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Prompt user for file and count number of characters &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; and lines in it*/ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE *fopen(), *fp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;int c , nc, nlines; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char filename[40] ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nlines = 0 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nc = 0; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;printf(“Enter file name: “); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gets( filename ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp = fopen( filename, “r” );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( fp == NULL ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for reading \n”, filename ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc( fp ) ; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (&amp;nbsp; c != EOF ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( c&amp;nbsp; ==&amp;nbsp; ‘\n’&amp;nbsp; )&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; nlines++ ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;st1:state&gt;&lt;st1:place&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;nc++&lt;/span&gt;&lt;/st1:place&gt;&lt;/st1:state&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt; ;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc ( fp ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose( fp ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( nc != 0 ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoBodyText2&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“There are %d characters in %s \n”, nc, filename ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“There are %d lines \n”, nlines );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“File: %s is empty \n”, filename ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Example 2&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;: Write a program to display&amp;nbsp; file contents 20 lines at a time. The program pauses after displaying 20 lines until the user presses either Q to quit or Return to display the next 20 lines. (The Unix operating system has a command called &lt;b&gt;more&lt;/b&gt; to do this ) As in previous programs, we read the filename from user and open it appropriately. We then process the file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; read character from file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; while not end of file and not finished do&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; begin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; display character&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if character is newline then&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; linecount = linecount + 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if linecount == 20 then&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; begin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; linecount = 1 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Prompt user and get reply;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read next character from file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; end&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* display.c: File display program */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* Prompt user for file and display it 20 lines at a time*/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;void main() &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE *fopen(), *fp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int c ,&amp;nbsp; linecount; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char filename[40], reply[40];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Enter file name: “); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gets( filename ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp = fopen( filename, “r” );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* open for reading */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( fp == NULL )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* check does file exist etc */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for reading \n”, filename ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; linecount = 1 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reply[0] = ‘\0’ ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc( fp ) ; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Read 1st character if any */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( c != EOF &amp;amp;&amp;amp;&amp;nbsp; reply[0] != ‘Q’ &amp;amp;&amp;amp; reply[0] != ‘q’) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar( c ) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Display character */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( c&amp;nbsp; ==&amp;nbsp; ‘\n’&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;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; linecount = linecount+ 1 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( linecount == 20 )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; linecount = 1 ;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; printf(“[Press Return to continue, Q to quit]”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; gets( reply ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc ( fp ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose( fp ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The string &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;reply&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; will contain the users response. The first character of this will be &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;reply[0]&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;. We check if this is ‘q’ or ‘Q’. The brackets [] in &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;printf&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; are used to distinguish the programs message from the file contents.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Example 3&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;: Write a program to compare two files specified by the user, displaying a message indicating whether the files are identical or different. This is the basis of a &lt;b&gt;compare&lt;/b&gt; command provided by most operating systems. Here our file processing loop is as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;read character ca from file A;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;read character cb from file B;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;while ca == cb and not EOF file A and not EOF file B&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;begin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; read character ca from file A;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; read character cb from file B;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;end&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;if ca == cb then&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printout(“Files identical”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printout(“Files differ”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;This program illustrates the use of I/O with two files. In general you can manipulate up to 20 files, but for most purposes not more than 4 files would be used. All of these examples illustrate the usefulness of processing files character by character. As you can see a number of Operating System programs such as compare, type, more, copy can be easily written using character I/O. These programs are normally called &lt;b&gt;system programs&lt;/b&gt; as they come with the operating system. The important point to note is that these programs are in no way special. They are no different in nature than any of the programs we have constructed so far.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* compare.c : compare two files */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;void main()&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE *fp1, *fp2, *fopen(); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int ca, cb; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char fname1[40], fname2[40] ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Enter first filename:”) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gets(fname1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Enter second filename:”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gets(fname2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp1 = fopen( fname1,&amp;nbsp; “r” );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* open for reading */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp2 = fopen( fname2,&amp;nbsp; “r” ) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* open for writing */&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( fp1 == NULL )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* check does file exist etc */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for reading \n”, fname1 ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if ( fp2 == NULL ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for reading \n”, fname2 ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* both files opened successfully&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ca&amp;nbsp; =&amp;nbsp; getc( fp1 ) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cb&amp;nbsp; =&amp;nbsp; getc( fp2 ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( ca != EOF&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp;&amp;nbsp;&amp;nbsp; cb != EOF&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp;&amp;nbsp;&amp;nbsp; ca == cb&amp;nbsp; ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; ca&amp;nbsp; =&amp;nbsp; getc( fp1 ) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; cb&amp;nbsp; =&amp;nbsp; getc( fp2 ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (&amp;nbsp; ca == cb )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; printf(“Files are identical \n”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if ( ca !=&amp;nbsp; cb )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; printf(“Files differ \n” );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose ( fp1 ); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose ( fp2 ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Times;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;&lt;/b&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Writing to Files&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The previous programs have opened files for reading and read characters from them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;To write to a file, the file must be opened for writing e.g.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp = fopen( fname, “w” );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;If the file does not exist already, it will be created.&amp;nbsp; If the file does exist, it will be overwritten!&amp;nbsp; So, be careful when opening files for writing, in case you destroy a file unintentionally. Opening files for writing can also fail. If you try to create a file in another users directory where you do not have access you will not be allowed and fopen will fail.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Character Output to Files&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The function &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;putc( c, fp )&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; writes a character to the file associated with the file pointer &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;fp&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Example&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&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; Write a file copy program which copies the file “prog.c” to “prog.old”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Outline solution:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Open files appropriately&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Check open succeeded&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Read characters from prog.c and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write characters to prog.old until all characters &amp;nbsp; copied&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h1 style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Close files&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The step: “Read characters .... and write ..” may be refined to:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; read character from prog.c&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; while not end of file do&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; begin&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; write character to prog.old&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read next character from prog.c&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; end&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* filecopy.c : Copy prog.c to prog.old */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;void main()&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE *fp1, *fp2, *fopen(); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int c ; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp1 = fopen( “prog.c”,&amp;nbsp; “r” );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* open for reading */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp2 = fopen( “prog.old”, “w” ) ; ../* open for writing */&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( fp1 == NULL )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* check does file exist etc */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open prog.c for reading \n” ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if ( fp2 == NULL ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open prog.old for writing \n”); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* both files O.K. */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc(fp1) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( c != EOF) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putc( c,&amp;nbsp; fp2);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* copy to prog.old */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c =&amp;nbsp; getc( fp1 ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose ( fp1 ); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Now close files */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose ( fp2 ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Files successfully copied \n”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Times;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The above program only copies the specific file &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.c&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; to the file &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.old&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;. We can make it a general purpose program by prompting the user for the files to be copied and opening them appropriately. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* copy.c : Copy any user file*/ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;void main()&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE *fp1, *fp2, *fopen(); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int c ; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char fname1[40], fname2[40] ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Enter source file:”) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gets(fname1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Enter destination file:”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gets(fname2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp1 = fopen( fname1,&amp;nbsp; “r” );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* open for reading */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp2 = fopen( fname2, “w” ) ; ../* open for writing */&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( fp1 == NULL )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* check does file exist etc */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for reading \n”, fname1 ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if ( fp2 == NULL ) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Cannot open %s for writing \n”, fname2 ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* terminate program */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* both files O.K. */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = getc(fp1) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* read from source */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ( c != EOF) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; putc( c,&amp;nbsp; fp2);&amp;nbsp;&amp;nbsp;&amp;nbsp; /* copy to destination */ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; c =&amp;nbsp; getc( fp1 ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose ( fp1 ); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Now close files */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose ( fp2 ); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“Files successfully copied \n”);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Times;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Command Line Parameters: Arguments to &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;main()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Accessing the command line arguments is a very useful facility. It enables you to provide commands with arguments that the command can use e.g. the command &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoHeader&quot; style=&quot;margin-right: -33.55pt; tab-stops: .5in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% cat prog.c&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;takes the argument &quot;prog.c&quot; and opens a file with that name, which it then displays. The command line argumenst include the command name itself so that in the above example, &quot;cat&quot; and &quot;prog.c&quot; are the command line arguments. The first argument i.e. &quot;cat&quot; is argument number zero, the next argument, &quot;prog.c&quot;, is argument number one and so on.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;To access these arguments from within a C program, you pass&amp;nbsp; parameters to the function &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;main()&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;. The use of arguments to &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;main&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is a key feature of many C programs. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp;The declaration of &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;main&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; looks like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; int main (int argc,&amp;nbsp; char *argv[])&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoHeader&quot; style=&quot;margin-right: -33.55pt; tab-stops: .5in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;This declaration states that &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 39.0pt; margin-right: -33.55pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list 39.0pt; text-indent: -21.0pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;1.&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;main&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; returns an integer value (used to determine if the program terminates successfully)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 39.0pt; margin-right: -33.55pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list 39.0pt; text-indent: -21.0pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;2.&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argc&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is the number of command line arguments including the command itself i.e &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argc&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; must be at least 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 39.0pt; margin-right: -33.55pt; margin-top: 0in; mso-list: l0 level1 lfo1; tab-stops: list 39.0pt; text-indent: -21.0pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;3.&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is an array of the command line arguments&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The declaration of &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; means that it is an array of pointers to strings (the command line arguments). By the normal rules about arguments whose type is array, what actually gets passed to main is the address of the first element of the array. As a result, an equivalent (and widely used) declaration is:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; int main (int argc,&amp;nbsp; char **argv)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;When the program starts, the following conditions hold true:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;o&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argc&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is greater than 0.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;o&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv[argc]&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is a null pointer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;o&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv[0]&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;, &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv[1]&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;, ..., &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv[argc-1]&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; are pointers to strings&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with implementation defined meanings.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;o&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv[0]&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is a string which contains the program’s name, or is an&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; empty string if the name isn’t available. Remaining members of&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;argv&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; are the program’s arguments.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Times;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Example: print_args echoes its arguments to the standard output – is a form of the Unix echo command.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoHeader&quot; style=&quot;margin-right: -33.55pt; tab-stops: .5in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* print_args.c: Echo command line arguments */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoHeader&quot; style=&quot;margin-right: -33.55pt; tab-stops: .5in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;int main(int argc,&amp;nbsp; char *argv[])&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i = 0 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int num_args ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;num_args = argc ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( num_args &amp;gt; 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(“%s\n“, argv[i]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i++ ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num_args--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;If the name of this program is &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;print_args&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt;, an example of its execution is as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% print_args hello goodbye solong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;print_args&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;hello&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;goodbye&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;solong&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;%&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;Exercise&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;: Rewrite &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;print_args &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;so that it operates like the Unix &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;echo&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt; command. &lt;b&gt;Hint&lt;/b&gt;: You only need to change the &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;printf&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt; statement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Times;&quot;&gt;&lt;br clear=&quot;all&quot; style=&quot;page-break-before: always;&quot; /&gt; &lt;/span&gt;  &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The following is a version of the Unix &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;cat&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; command:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/* cat1.c: Display files specified as command line parameters */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;int main(int argc,&amp;nbsp; char *argv[])&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i&amp;nbsp; = 1 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int c ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;int num_args = 0 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;SV&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;FILE *fp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( argc == 1 )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr, &quot;No input files\nUsage: % cat file…\n&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( argc &amp;gt; 1 )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; printf(&quot;%d files to be displayed\n&quot;, argc-1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num_args = argc - 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( num_args &amp;gt; 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; printf(&quot;[Displaying file %s]\n&quot;, argv[i]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; num_args--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; fp = fopen( argv[i], &quot;r&quot; ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; if ( fp == NULL )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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;fprintf(stderr,&quot;Cannot display %s \n&quot;, argv[i]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; continue; /* Goto next file in list */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; c = getc(fp) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; while ( c != EOF )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; putchar( c );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; c = getc( fp );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; fclose( fp );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoBodyText3&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; printf(&quot;\n[End of %s]\n--------------\n\n&quot;, argv[i]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; i++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;: The &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;continue&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; statement causes the current iteration of the loop to stop and control to return to the loop test.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The following is a version of the Unix &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;wc&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; command called &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;count&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; which operates as follows&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% count prog.c&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.c: 300 characters&amp;nbsp;&amp;nbsp; 20 lines&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% count –l prog.c&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.c: 20 lines&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% count –w prog.c&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;prog.c: 300 characters&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;/*count.c : Count lines and characters in a file */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;int main(int argc,&amp;nbsp; char *argv[])&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int c , nc, nlines;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;FR&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;char filename[120];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE *fp, *fopen();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( argc == 1 )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr, &quot;No input files\n&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr, &quot;Usage: \% count [-l] [w] file\n&quot;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nlines = 0 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nc = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((strcmp(&quot;-l&quot;, argv[1]) == 0)&amp;nbsp; ||&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (strcmp(&quot;-w&quot;, argv[1]) == 0) )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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;&amp;nbsp; strcpy(filename, argv[2]) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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;&amp;nbsp; strcpy(filename, argv[1]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp = fopen( filename, &quot;r&quot; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( fp == NULL )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,&quot;Cannot open %s\n&quot;, filename );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: -33.55pt; margin-top: 0in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp; c = getc( fp ) ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (&amp;nbsp; c != EOF )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; if ( c&amp;nbsp; ==&amp;nbsp; &#39;\n&#39;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; nlines++ ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; &lt;/span&gt;&lt;st1:state&gt;&lt;st1:place&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;nc++&lt;/span&gt;&lt;/st1:place&gt;&lt;/st1:state&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt; ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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; c = getc ( fp );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fclose( fp );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( strcmp(argv[1], &quot;-w&quot;) == 0 )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&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;printf(&quot;%s: %d characters \n&quot;, filename, nc );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if ( strcmp(argv[1], &quot;-l&quot;) == 0 )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%s: %d lines \n&quot;, filename, nlines );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%s: %d characters&amp;nbsp; %d lines\n&quot;, filename, nc, nlines );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Logical OR is represented by &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;||&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt; in the code above. Logical AND is represented by &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt; in C.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The function &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;strcpy()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is one of many library string handling functions. It takes two strings as arguments and copies the second argument to the first i.e. it operates as a form of string assignment. In C you &lt;b&gt;CANNOT&lt;/b&gt; assign strings as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-indent: .5in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;filename = &quot;prog.c&quot;&amp;nbsp; /* WRONG */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-indent: .5in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-indent: .5in;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;strcpy( filename, &quot;prog.c&quot;);&amp;nbsp;&amp;nbsp; /* CORRECT */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;The function &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;strcmp()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt; is another string handling function. It takes two strings as arguments and returns 0 if the two strings are the same. As for assignment, you cannot test string equality with == i.e.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;if (filename == &quot;prog.c&quot;)&amp;nbsp; /* WRONG */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;if (strcmp(filename,&quot;prog.c&quot;)==0)&amp;nbsp; /* CORRECT */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Note: The above program crashes if you run it as:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% count –w &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;or&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% count –l&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;This is because in these cases we failed to test if there was a 3&lt;sup&gt;rd&lt;/sup&gt; argument containing the filename to be processed. We simply try to access this non-existent argument and so cause a memory violation. This gives rise to a so-called &quot;&lt;b&gt;bus error&lt;/b&gt;&quot; in a Unix environment.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot;&gt;As an exercise, insert code to correct this failure.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;Exercise&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-GB&quot;&gt;: Write a &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;copy&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; command to operate like the Unix &lt;/span&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;cp&lt;/span&gt;&lt;span lang=&quot;EN-GB&quot;&gt; command that takes it files from the command line: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-right: -33.55pt; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-GB&quot; style=&quot;font-family: Courier;&quot;&gt;% copy file newfile&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/4462455856275751549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/11/file-handling-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/4462455856275751549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/4462455856275751549'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/11/file-handling-in-c.html' title='File Handling in C'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-2151396590278668019</id><published>2011-10-31T00:34:00.000-07:00</published><updated>2011-10-31T00:34:08.026-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to delete duplicate elements in an array</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;int main(){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; int arr[50];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; int *p;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; int i,j,k,size,n;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; printf(&quot;\nEnter size of the array: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; printf(&quot;\nEnter %d elements into the array: &quot;,n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;arr[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; size=n;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; p=arr;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; for(i=0;i&amp;lt;size;i++){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;size;j++){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(i==j){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if(*(p+i)==*(p+j)){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;k=j;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;size--;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while(k &amp;lt; size){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*(p+k)=*(p+k+1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;k++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j=0;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; printf(&quot;\nThe array after removing duplicates is: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; for(i=0;i &amp;lt; size;i++){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; printf(&quot; %d&quot;,arr[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; return 0;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/2151396590278668019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-delete-duplicate-elements-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/2151396590278668019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/2151396590278668019'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-delete-duplicate-elements-in.html' title='Program to delete duplicate elements in an array'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-3422394602793072387</id><published>2011-10-31T00:33:00.000-07:00</published><updated>2011-10-31T00:33:06.959-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to concatenate two strings without using string functions</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;conio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;void main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; char a[50],b[50];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; int i,j,n,k;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; clrscr();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; printf(&quot;\n Please Give The STRING OF A : &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,a);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; printf(&quot;\n Please Give The STRING OF B : &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,b);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; for(i=0,k=0;a[i]!=&#39;\0&#39;;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; k++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; for(j=0,n=0;b[j]!=&#39;\0&#39;;j++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; printf(&quot;VALUE OF K=%d&quot;,k);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; printf(&quot;VALUE OF N=%d&quot;,n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; for(i=k,j=0;i&amp;lt;=n+k;i++,j++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a[i]=b[j];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; printf(&quot;\n THE Concatenated string is %s .&quot;,a);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; getch();&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/3422394602793072387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-concatenate-two-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/3422394602793072387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/3422394602793072387'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-concatenate-two-strings.html' title='Program to concatenate two strings without using string functions'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-7155108352237977384</id><published>2011-10-31T00:29:00.001-07:00</published><updated>2011-10-31T00:29:27.211-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to sort an array using bubble sort</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int n,i,j,temp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the number of elements: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int a[n];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the elements in the array\n&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=i+1;j&amp;lt;n;j++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; if(a[i]&amp;gt;a[j])&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; &amp;nbsp; &amp;nbsp; temp=a[i];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; &amp;nbsp; &amp;nbsp; a[i]=a[j];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; &amp;nbsp; &amp;nbsp; a[j]=temp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nThe sorted array is - \n&quot; );&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d, &quot;,a[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/7155108352237977384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-sort-array-using-bubble-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/7155108352237977384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/7155108352237977384'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-sort-array-using-bubble-sort.html' title='Program to sort an array using bubble sort'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-8583157566087724647</id><published>2011-10-31T00:28:00.000-07:00</published><updated>2011-10-31T00:28:32.464-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to count number of sentences words and letters in a paragraph</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char ch[150];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i,c=0,c1=0,c2=0;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter a Paragraph \n&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gets(ch);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;ch[i]!=&#39;\0&#39;;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(ch[i]==&#39;.&#39;||ch[i]==&#39;!&#39;||ch[i]==&#39;?&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; c++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; c1++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(ch[i]==&#39; &#39;||ch[i]==&#39;,&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; c1++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(ch[i]&amp;gt;65&amp;amp;&amp;amp;ch[i]&amp;lt;123)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; c2++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nNumber of letters = %d \nNumber of words=%d &quot;,c2,c1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nNumber of Sentences = %d\n&quot;,c);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/8583157566087724647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-count-number-of-sentences.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/8583157566087724647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/8583157566087724647'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-count-number-of-sentences.html' title='Program to count number of sentences words and letters in a paragraph'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-7302332224205969299</id><published>2011-10-31T00:27:00.000-07:00</published><updated>2011-10-31T00:27:20.743-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to search an element using linear search or binary search (menu driven program)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;void main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;int a[25],beg,item,last,n,num,i,ch,mid,f=0;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;menu\n&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n 1.linear search&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n 2.binary search&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n enter the choice&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;scanf(&quot;%d&quot;,&amp;amp;ch);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;if(ch==1)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n enter the number of elements in the array&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;scanf(&quot;%d&quot;,&amp;amp;n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n enter the sorted array&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n enter the item to be searched&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;scanf(&quot;%d&quot;,&amp;amp;item);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;if(a[i]==item)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n item found at position%d&quot;,i+1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;break;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;if(i==n)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n item not found&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;if(ch==2)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\nenter the number of elements in the array&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;scanf(&quot;%d&quot;,&amp;amp;n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;enter the sorted array&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;item to be searched&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;scanf(&quot;%d&quot;,&amp;amp;item);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;last=n-1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;mid=(beg+last)/2;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;while(beg&amp;lt;=last)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;if(item==a[mid])&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;\n item found at position %d&quot;,mid+1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;break;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else if(a[mid]&amp;gt;item)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;last=mid-1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else beg=mid+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;mid=(beg+last)/2;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/7302332224205969299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-search-element-using-linear.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/7302332224205969299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/7302332224205969299'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-search-element-using-linear.html' title='Program to search an element using linear search or binary search (menu driven program)'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-447103028125492129</id><published>2011-10-31T00:25:00.000-07:00</published><updated>2011-10-31T00:25:15.419-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to convert a string to upper case</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;string.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char s[50];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i,l;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter some text: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gets(s);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l=strlen(s);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;l;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(s[i]&amp;gt;=&#39;a&#39;&amp;amp;&amp;amp;s[i]&amp;lt;=&#39;z&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; s[i]-=32;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Text after converting to upper case: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; puts(s);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/447103028125492129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-convert-string-to-upper-case.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/447103028125492129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/447103028125492129'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-convert-string-to-upper-case.html' title='Program to convert a string to upper case'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-4995389103942899814</id><published>2011-10-31T00:24:00.000-07:00</published><updated>2011-10-31T00:24:17.182-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to copy a file to another file</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;void main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILE *fp1,*fp2;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char ch;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char fname1[30],fname2[30];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the source file: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fflush(stdin);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,fname1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the destination file: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fflush(stdin);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,fname2);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fp1=fopen(fname1,&quot;r&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fp2=fopen(fname2,&quot;w&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(fp1==NULL)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n cannot open file %s for reading&quot;,fname1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit(1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(fp2==NULL)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n cannot open file %s for writing&quot;,fname2);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit(1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ch=getc(fp1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(ch!=EOF)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; putc(ch,fp2);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ch=getc(fp1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fclose(fp1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fclose(fp2);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n files copied&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/4995389103942899814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-copy-file-to-another-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/4995389103942899814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/4995389103942899814'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-copy-file-to-another-file.html' title='Program to copy a file to another file'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-1371612139458038848</id><published>2011-10-31T00:23:00.000-07:00</published><updated>2011-10-31T00:23:19.475-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to count vowels consonents and spaces in a string</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;int i,cons=0,vow=0,sp=0;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;char a[100];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;Enter the sentence\n&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;gets(a);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;for(i=0;a[i]!=&#39;\0&#39;;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;if(a[i]==&#39;a&#39;||a[i]==&#39;A&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;vow=vow+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else if(a[i]==&#39;e&#39;||a[i]==&#39;E&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;vow=vow+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else if(a[i]==&#39;i&#39;||a[i]==&#39;I&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;vow=vow+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else if(a[i]==&#39;o&#39;||a[i]==&#39;O&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;vow=vow+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else if(a[i]==&#39;u&#39;||a[i]==&#39;U&#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;vow=vow+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else if(a[i]==&#39; &#39;)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;sp=sp+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;else&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;cons=cons+1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;Total number of vowels entered = %d\n&quot;,vow);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;Total number of consonents entered = %d\n&quot;,cons);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;printf(&quot;Total number of spaces entered = %d\n&quot;,sp);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/1371612139458038848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-count-vowels-consonents-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/1371612139458038848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/1371612139458038848'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-count-vowels-consonents-and.html' title='Program to count vowels consonents and spaces in a string'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-9205141626622728167</id><published>2011-10-31T00:21:00.001-07:00</published><updated>2011-10-31T00:21:58.519-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to find smallest in an array using pointer</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;main()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;{&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i,n;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nHow many elements?: &quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int a[n];&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Element %d: &quot;,i+1);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nCreating pointer now...&quot;);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int *p,small;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p = a;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; small=*p;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i=1;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(i&amp;lt;n)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(small &amp;gt; *p)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; small=*p;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p++;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nSmallest number: %d \n&quot;,small);&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;}&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/9205141626622728167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-find-smallest-in-array-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/9205141626622728167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/9205141626622728167'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-find-smallest-in-array-using.html' title='Program to find smallest in an array using pointer'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6097164267918317497.post-6649625763578679231</id><published>2011-10-31T00:20:00.000-07:00</published><updated>2011-10-31T00:20:26.535-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Programming"/><title type='text'>Program to merge and sort two arrays</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;void sort(int a[],int);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;void main()&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int a[20],c[10],i,m,n,j;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the no.of elements in 1st array- \n&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;m);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the 1st array - \n&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the no.of elements in the 2nd array&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Enter the 2nd array&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;c[i]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sort(a,m);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;1st sorted array - \n&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d, &quot;,a[i]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sort(c,n);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;2nd sorted array - \n&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d, &quot;,c[i]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j=m;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {a[j]=c[i];&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j++;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sort(a,m+n);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Merged and Sorted array - \n&quot;);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;m+n;i++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d, &quot;,a[i]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;void sort(int a[],int n)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i,j,temp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=i+1;j&amp;lt;n;j++)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; if(a[i]&amp;gt;a[j])&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; temp=a[i];&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; a[i]=a[j];&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; a[j]=temp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&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; }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://iprogramer.blogspot.com/feeds/6649625763578679231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-merge-and-sort-two-arrays.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/6649625763578679231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6097164267918317497/posts/default/6649625763578679231'/><link rel='alternate' type='text/html' href='http://iprogramer.blogspot.com/2011/10/program-to-merge-and-sort-two-arrays.html' title='Program to merge and sort two arrays'/><author><name>ipr</name><uri>http://www.blogger.com/profile/04428714945726410439</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>