1
A Quick Start
1.1 Introduction
It is always difficult to start describing a programming language because little
details do not make much sense until one knows enough to understand the "big
picture." In this chapter, I try to give you a glimpse of the big picture by looking at a
sample program and explaining its workings line by line. This sample program also
shows you how familiar procedures are accomplished in C. This information plus the
other topics discussed in the chapter introduce you to the basics of the C language so
that you can begin writing useful programs.
The program we dissect reads text from the standard input, modifies it, and
writes it to the standard output. Program l.l first reads a list of column numbers. These
numbers are pairs and indicate ranges of columns in the input line. The list is
terminated with a negative number. The remaining input lines are read and printed,
then the selected columns from the input lines are extracted and primed. Note that the
first column in a line is number zero. For example, if the input is
4 9 12 20 -1
abcdefghijklmnopqrstuvwxyz
Hello there, how are you?
I
am
fine,
thanks.
See you!
Bye
then the program would produce:
Original input
:
abcdefghijklmnopqxstuvwxyz
Rearranged
line:
efghijmnopqrstu