Programming in ANSI C 6th Edition E. Balagurusamy download
Programming in ANSI C 6th Edition E. Balagurusamy download
Balagurusamy download
https://ebookgate.com/product/programming-in-ansi-c-6th-edition-
e-balagurusamy/
https://ebookgate.com/product/c-programming-data-structures-4th-
edition-e-balagurusamy/
https://ebookgate.com/product/computer-programming-1st-edition-e-
balagurusamy/
https://ebookgate.com/product/programming-with-ansi-c-2nd-ed-
edition-trivedi/
https://ebookgate.com/product/an-introduction-to-programming-
with-c-6th-edition-diane-zak/
Beginning ANSI C The Complete Language 3rd Edition Ivor
Horton
https://ebookgate.com/product/beginning-ansi-c-the-complete-
language-3rd-edition-ivor-horton/
https://ebookgate.com/product/c-programming-program-design-
including-data-structures-6th-edition-d-s-malik/
https://ebookgate.com/product/object-oriented-programming-
with-c-2-e-second-edition-sahay/
https://ebookgate.com/product/programming-in-c-2nd-edition-
safari/
https://ebookgate.com/product/java-programming-6th-edition-joyce-
farrell/
PROGRAMMING IN
ANSI C
— Sixth Edition —
ABOUT THE AUTHOR
E Balagurusamy, is presently the Chairman of EBG Foundation, Coimbatore. In the past he has also
held the positions of member, Union Public Service Commission, New Delhi and Vice-Chancellor, Anna
Fundamentals of Computers
Computing Fundamentals and C Programming
Programming in C#, 3/e
Programming in Java, 4/e
Object-Oriented Programming with C++, 5/e
Programming in BASIC, 3/e
Numerical Methods
Reliability Engineering
A recipient of numerous honors and awards, he has been listed in the Directory of Who’s Who of
PROGRAMMING IN
ANSI C
— Sixth Edition —
E Balagurusamy
Chairman
EBG Foundation
Coimbatore
McGraw-Hill Offices
New Delhi New York St Louis San Francisco Auckland Bogotá Caracas
Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal
San Juan Santiago Singapore Sydney Tokyo Toronto
Tata McGraw-Hill
Published by the Tata McGraw Hill Education Private Limited,
7 West Patel Nagar, New Delhi 110 008.
Copyright © 2012, 2011, 2007, 2004, 2002, 1992, 1982 by Tata McGraw Hill Education Private Limited.
No part of this publication may be reproduced or distributed in any form or by any means, electronic,
mechanical, photocopying, recording, or otherwise or stored in a database or retrieval system without
the prior written permission of the publishers. The program listings (if any) may be entered, stored and
executed in a computer system, but they may not be reproduced for publication.
Information contained in this work has been obtained by Tata McGraw-Hill, from sources believed to be
reliable. However, neither Tata McGraw-Hill nor its authors guarantee the accuracy or completeness of
any information published herein, and neither Tata McGraw-Hill nor its authors shall be responsible for
any errors, omissions, or damages arising out of use of this information. This work is published with the
understanding that Tata McGraw-Hill and its authors are supplying information but are not attempting
to render engineering or other professional services. If such services are required, the assistance of an
appropriate professional should be sought.
Typeset at Tej Composers, WZ-391, Madipur, New Delhi 110063, and printed at
Cover Printer:
CONTENTS
1 Overview of C 1
1.1 History of C 1
1.2 Importance of C 3
3
6
7
9
10
12
13
14
1.11 Unix System 14
1.12 MS-D System 17
Review Questions 18
Programming Exercises 20
45
Review Questions 48
Programming Exercises 50
131
135
Review Questions 143
Programming Exercises 147
7 Arrays 192
7.1 Introduction 192
194
195
197
203
207
7.7 Multi-Dimensional Arrays 215
7.8 Dynamic Arrays 216
7.9 More about Arrays 217
Review Questions 230
Programming Exercises 233
11 Pointers 357
11.1 Introduction 357
357
360
361
11.5 Initialization of Pointer Variables 362
363
11.7 Chain of Pointers 366
11.8 Pointer Expressions 366
11.9 Pointer Increments and Scale Factor 368
11.10 Pointers and Arrays 369
372
11.12 Array of Pointers 374
375
378
11.15 Pointers to Functions 379
11.16 Pointers and Structures 382
384
Review Questions 391
Programming Exercises 394
428
429
431
435
438
440
Review Questions 448
Programming Exercises 450
Bibliography 555
Index 556
C
New to this Edition
pleasurable activity!
and their execution. Chapter 2 discusses how to declare the constants, variables and data types.
Chapter 3 Chapter 4 details
Chapter 5
Chapter 6
Chapters 7 and 8
covered in Chapter 8. are on functions, structures and unions. Pointers, perhaps
Chapter 11 in the most user-friendly manner.
Chapters 12 and 13 Chapter 14
Chapter 15
xii Preface to the Sixth Edition
and educational.
areas.
Numerous chapter-end questions and exercises provide ample opportunities to the readers to
review the concepts learned and to practice their applications.
questions
Separate appendix dedicated to latest compiler C99 features
Web Supplement
http://www.mhhe.com/balagurusamy/ansic6 which
E Balagurusamy
Publisher’s Note
[email protected]
Please report any piracy spotted by you as well!
1 OVERVIEW OF C
Key Terms
printf I Program
1.1 HISTORY OF C
‘C’ seems a strange name for a programming language. But this strange sounding language is one of
the most popular computer languages today because it is a structured, high-level, machine independent
language. It allows software developers to develop programs without worrying about the hardware
platforms where they will be implemented.
The root of all modern languages is ALGOL, introduced in the early 1960s. ALGOL was the
widely used in Europe. ALGOL gave the concept of structured programming to the computer science
In 1967, Martin Richards developed a language called BCPL (Basic Combined Programming
Language) primarily for writing system software. In 1970, Ken Thompson created a language using
system at Bell Laboratories. Both BCPL and B were “typeless” system programming languages.
many concepts from these languages and added the concept of data types and other powerful features.
superhighway.
For many years, C was used mainly in academic environments, but eventually with the release of
support among computer professionals. Today, C is running under a variety of operating system and
hardware platforms.
traditional C”. The language became more
‘The C Programming Language’
the programming community. The rapid growth of C led to the development of different versions of the
language that were similar but often incompatible. This posed a serious problem for system developers.
2 Programming in ANSI C
Java modelled on C
All popular computer languages are dynamic in nature. They continue to improve their power and
the usefulness of the language. The result was the 1999 standard for C. This version is usually referred
to as C99. The history and development of C is illustrated in Fig. 1.1
Although C99 is an improved version, still many commonly available compilers do not support all of
the new features incorporated in C99. We, therefore, discuss all the new features added by C99 in an
1.2 IMPORTANCE OF C
whose rich set of built-in functions and operators can be used to write any complex program. The C
compiler combines the capabilities of an assembly language with the features of a high-level language
operating system.
Another important feature of C is its ability to extend itself. A C program is basically a collection of
functions that are supported by the C library. We can continuously add our own functions to C library.
main( )
{
/*…………printing begins………………*/
printf(“I see, I remember”);
/*………………printing ends…………………*/
}
program is main and the execution begins at this line. The main( ) is a special function used by the
C system to tell the computer where the program starts. Every program must have exactly one main
function. If we use more than one main
beginning of the program.
The empty pair of parentheses immediately following main indicates that the function main has no
arguments (or parameters). The concept of arguments will be discussed in detail later when we discuss
functions (in Chapter 9).
The opening brace “{ main and the closing
end of the program. All the statements between these two braces form the function body. The function
In this case, the function body contains three statements out of which only the printf line is an
executable statement. The lines beginning with /* and ending with */ comment lines. These
are used in a program to enhance its readability and understanding. Comment lines are not executable
statements and therefore anything between /* and *
/* = = = =/* = = = = */ = = = = */
is not valid and therefore results in an error.
use them liberally in our programs. They help the programmers and other users in understanding the
various functions and operations of a program and serve as an aid to debugging and testing. We shall
see the use of comment lines more in the examples that follow.
printf( ) function, the only executable statement of the program.
printf(“I see, I remember”);
printf means that it is a function that
I see,
I remember!
This can be achieved by adding another printf function as shown below:
printf(”I see, \n”);
printf(“I remember !”);
The information contained between the parentheses is called the argument of the function. This
printf function is “I see, \n” and the second is “I remember !”. These arguments are
simply strings of characters to be printed out.
Overview of C 5
a typewriter. After printing the character comma (,) the presence of the newline character \n causes the
and I.
It is also possible to produce two or more lines of output by one printf statement with the use of
newline character at appropriate places. For example, the statement
printf(“I see,\n I remember !”);
will output
I see,
I remember !
while the statement
printf( “I\n.. see,\n… … … I\n… … … remember !”);
will print out
I
.. see,
… … … I
… … … remember !
#include <stdio.h>
a distinction between uppercase and lowercase letters. For example, printf and PRINTF are not the
REMEMBER”.
The above example that printed I see, I remember is one of the simplest programs. Figure 1.3
highlights the general format of such simple programs. All C programs need a main function.
Program statements
End of program
beginning to give information such as name of the program, author, date, etc. Comment characters are
also used in other lines to indicate line numbers.
The words number and amount are variable names that are used to store numeric data. The
numeric data may be either in integer form or in real form. In C, all variables should be declared to tell
the compiler what the variable names are and what type of data they hold. The variables must be
declared before they are used. In lines 5 and 6, the declarations
int number;
float amount;
tell the compiler that number is an integer (int) and amount (
The words such as int and are called the keywords and cannot be used as variable names. A
assigning a data value to it. This is done in lines 8 and 10. In line-8,
an integer value 100 is assigned to the integer variable number and in line-10, the result of addition of
amount. The statements
number = 100;
amount = 30.75 + 75.35;
are called the assignment statements. Every assignment statement must have a semicolon at the end.
The next statement is an output statement that prints the value of number. The print statement
printf(“%d\n”, number);
In the program, the variable value represents the value of money at the end of the year while amount
represents the value of money at the start of the year. The statement
amount = value ;
current year as the value at start of the next year.
8 Programming in ANSI C
Let us consider the new features introduced in this program. The second and third lines begin with
instructions. A symbolic constant for use in the program.
Whenever a symbolic name is encountered, the compiler substitutes the value associated with the
0 5000.00
1 5550.00
2 6160.50
3 6838.15
4 7590.35
5 8425.29
6 9352.07
7 10380.00
8 11522.69
9 12790.00
10 14197.11
The Directive
A is a preprocessor compiler directive and not a statement. Therefore lines should
easily distinguished from lowercase variable names. instructions are usually placed at the
beginning before the main()
as
float amount;
float value;
float inrate;
When two or more variables are declared in one statement, they are separated by a comma.
All computations and printing are accomplished in a while loop. while is a mechanism for evaluating
repeatedly a statement or a group of statements. In this case as long as the value of year is less than or
PERIOD, the four statements that follow while
statements are grouped by braces. We exit the loop when year becomes greater than PERIOD. The
concept and types of loops are discussed in Chapter 6.
in Chapter 3.
Figure 1.7 presents a very simple program that uses a mul ( ) function. The program will print the
following output.
Multiplication of 5 and 10 is 50
int a, b, c;
a = 5;
b = 10;
c = mul (a,b);
Fig. 1.7
The mul ( ) function multiplies the values of x and y and the result is returned to the main ( ) function
when it is called in the statement
c = mul (a, b);
The mul ( ) has two arguments x and y that are declared as integers. The values of a and b are
passed on to x and y respectively when the function mul ( )
considered in detail in chapter 9.
part of C math library. If we want to use any of these mathematical functions, we must add an #include
#include <math.h>
math.h
headings.
main ( )
{
int angle;
float x,y;
angle = 0;
printf(“ Angle Cos(angle)\n\n”);
while(angle <= MAX)
{
x = (PI/MAX)*angle;
y = cos(x);
printf(“%15d %13.4f\n”, angle, y);
angle = angle + 10;
}
}
Output
Angle Cos(angle)
0 1.0000
10 0.9848
20 0.9397
30 0.8660
40 0.7660
50 0.6428
60 0.5000
70 0.3420
80 0.1736
90 –0.0000
100 –0.1737
110 –0.3420
120 –0.5000
130 –0.6428
140 –0.7660
150 –0.8660
160 –0.9397
170 –0.9848
180 –1.0000
Another #include
#include <stdio.h>
stdio.h refers to the standard
12 Programming in ANSI C
called functions. A function is a subroutine that may include one or more statements designed to perform
a
may contain one or more sections as shown in Fig. 1.9.
The documentation section consists of a set of comment lines giving the name of the program,
symbolic constants.
global
variables and are declared in the global declaration section that is outside of all the functions. This
Every C program must have one main() function section. This section contains two parts, declaration
part and executable part. The declaration part declares all the variables used in the executable part.
There is at least one statement in the executable part. These two parts must appear between the
opening and the closing braces. The program execution begins at the opening brace and ends at the
closing brace. The closing brace of the main function section is the logical end of the program. All
statements in the declaration and executable parts end with a semicolon(;).
main function.
main function, although they may
appear in any order.
All sections, except the main
the braces are aligned and the statements are indented in the program of Fig. 1.5.
a = b;
x = y + 1;
z = a + x;
can be written on one line as
a = b; x = y+1; z = a+x;
The program
main( )
{
printf(“hello C”);
}
comments not only increase the readability but also help to understand the program logic. This is very
important for debugging and testing the program.
Figure 1.10 illustrates the process of creating, compiling and executing a C program. Although these
steps remain the same irrespective of the system commands for implementing the
steps and conventions for naming may differ on different systems.
output operations are channeled through the operating system. The operating system, which is an
interface between the hardware and the user, handles the execution of user programs.
ed filename
to receive the new program. Any corrections in the program are done under the editor. (The name of
System Ready
Source Program
Edit
Source Program
Compile
C Compiler
Source Program
Syntax Yes
Errors ?
No Object Code
Link with
System Library
System Library
No Errors
CORRECT OUTPUT
Stop
cc ebg1.c
The source program instructions are now translated into a form that is suitable for execution by the
computer. The translation is done after examining each instruction for its correctness. If everything is
cc filename - lm
a.out
program does not produce the desired results. Perhaps, something is wrong with the program logic or
data. Then it would be necessary to correct the source program or the data. In case the source program
mv a.out name
We may also achieve this by specifying an option in the cc command as follows:
cc –o name source-file
a.out from being
destroyed.
filename-i.o
a.out as shown in Fig. 1.11.
cc –c mod1.c
cc –c mod2.c
mod1.c and mod2.c mod1.o and mod2.o. They can be
cc mod1.o mod2.o
Overview of C 17
.C .C .C
Compiler and
preprocessor
.O .O .O Library
Linker
a.out
Fig. 1.11
cc mod1.c mod2.o
Only mod1.c
LINK pay.obj
which generates the executable code pay.exe
pay
would execute the program and give the results.
Just Remember
∑ main() main() is illegal). The place
main is where the program execution begins.
∑ The execution of a function begins at the opening brace of the function and ends at the
corresponding closing brace.
∑
names and output strings.
∑ All the words in a program line must be separated from each other by at least one space, or a tab,
∑ Compiler directives such as and include are special instructions to the compiler to help it
compile a program. They do not end with a semicolon.
∑
∑
closing brace.
∑ C is a free-form language and therefore a proper form of indentation of various sections would
improve legibility of the program.
∑
in proper places increases readability and understandability of the program and helps users in
Review Questions
true or false.
(a) Every line in a C program should end with a semicolon.
true?
on the screen.
1.5 Remove the semicolon at the end of the printf
it. What is the output?
Overview of C 19
message?
Year Amount
1 5500.00
Programming Exercises
1.1 Write a program that will print your mailing address in the following form:
1.8 Given the values of three variables a, b and c, write a program to compute and display the value
of x, where
a
x=
b-c
Execute your program for the following values:
x= y=
sum
Product =
2 CONSTANTS, VARIABLES,
AND DATA TYPES
Key Terms
2.1 INTRODUCTION
data
information.
program.
syntax rules
grammar
Trigraph Characters
Constants, Variables, and Data Types 23
Letters Digits
Special Characters
White Spaces
24 Programming in ANSI C
2.3 C TOKENS
tokens
C TOKENS
main []
amount {}
Note C99 adds some more keywords. See the Appendix “C99 Features”.
2.5 CONSTANTS
Integer Constants
integer decimal
octal hexadecimal
26 Programming in ANSI C
Note
octal
hexadecimal
Program 2.1
Constants, Variables, and Data Types 27
Program
main()
{
printf(“Integer values\n\n”);
printf(“%d %d %d\n”, 32767,32767+1,32767+10);
printf(“\n”);
printf(“Long integer values\n\n”);
printf(“%ld %ld %ld\n”, 32767L,32767L+1L,32767L+10L);
}
Output
Integer values
32767 -32768 -32759
Long integer values
32767 32768 3777
Real Constants
real
decimal notation
exponential notation
mantissa e exponent
mantissa decimal notation exponent
plus minus sign e
28 Programming in ANSI C
single
number 5.
printf(“%d”, ‘a’);
printf(“%c”, ‘97’);
String Constants
double
Constants, Variables, and Data Types 29
escape sequences.
Constant Meaning
2.6 VARIABLES
variable
amount
30 Programming in ANSI C
Total total
TOTAL.
(int), char
double) void.
long int long double
Note C99 adds three more data types, namely _Bool Complex, and _Imaginary. See the
Appendix “C99Fatures”.
Integral Type
Integer Character
Table 2.7 Size and Range of Basic Data Types on 16-bit Machines
int
32 Programming in ANSI C
Integer Types
short int
short int, int, long int
int, signed unsigned
long int
int
Note C99 allows long long integer types. See the Appendix “C99 Features”.
Type Range
Constants, Variables, and Data Types 33
float
double
long double
Void Types
void
void
Character Types
character(char)
signed unsigned
unsigned chars signed chars
data-type v1,v2,....vn ;
int count;
int number, total;
double ratio;
Other documents randomly have
different content
CHAPTER XI
SEARCHING FOR THE MAN WITH A SCARRED
HEEL
Mr. Ryder’s prediction came true. It was not two days later when a
half dozen peons appeared on the edge of the forest and occupied
their time shooting out the windows in the workmen’s cottages and
sending leaden greetings to any one who appeared out of doors.
They remained in their positions until the soldiers mounted a light
machine gun in the window of the barracks house and poured a rain
of steel-jacketed bullets in their direction. But José Cerro’s followers
were not the only ones who were made bold by the withdrawal of
the troops. The traitor inside the power plant became active too.
One evening while Jack and Mr. Ryder were partaking of one of
Tom Why’s elaborate meals, Phil Underwood, the young American
whose duty it was to take care of the huge searchlight, rushed into
the dining room.
“Mr. Ryder,” he exclaimed with a savage note in his voice, “there’s
a peon in Necaxa I’d like to lay hands on. He’s that blasted
sympathizer. If I knew who he was I’d choke him to death. What do
you think he’s done now to help that bunch of cutthroats out there
in the mountain? He’s put the big searchlight out of business! He’s
wrecked the entire outfit and there isn’t a place this side of New
York where we can get the broken parts replaced! It looks as if we
were up against it for sure.”
The engineer looked thoroughly worried.
“When did it happen?” he demanded.
“The light was all right up to dawn this morning. I shut it off
promptly at four o’clock, put the canvas jacket over it and went to
bed. When I tried to start it a few moments ago I found the whole
mechanism gone to smash.”
For a long time Mr. Ryder was silent. His brow was wrinkled and it
was evident to both Phil and Jack that the situation was causing him
some deep thought. Finally he spoke.
“Look here, Phil, this condition is mighty serious and I am at a loss
to know exactly how to proceed. I think the best plan is not to
mention this last piece of treachery. Merely go to Lieutenant
Hernandez and tell him that the searchlight suddenly became out of
order and until we can repair it or make better arrangements he
must keep a double guard along the barricade and the first trench. If
we spread the news about this broadcast we can’t tell what sort of
an effect it will have on the soldiers. Mexicans are a peculiar lot, you
know, and for that reason alone I think it would be far better for us
to keep this incident secret. In the meantime you and Jack and
myself can keep a watchful eye on everything in general and I’ll try
to work out a plan for an improvised searchlight.”
“Very good, sir,” said Phil, as he hurried off to the military
barracks.
When the youth had gone Mr. Ryder turned to Jack and said: “I
trust you are still willing to help me in this difficulty, my boy.”
“You’re right I am,” exclaimed Jack enthusiastically, “I am as much
interested as if I were employed here and I’ll do anything I can to be
of assistance.”
“Very well then, Jack, I’ll look to you to do a man’s share of the
watching around here until we can get things straightened out. This
trouble with the searchlight may mean that a night attack is
impending. I purpose doing some guard duty myself to-night and I
should like to have you help me out. Will you?”
“Only tell me what you want of me and I’ll do it without a word of
protest,” said Jack loyally.
“Well, suppose you buckle on your revolver now and start
patroling the village. Keep an eye out for anything that does not look
absolutely normal. At midnight report back to the cottage here and
wake me up. I’ll do my trick between midnight and dawn, for I do
not intend that this traitor shall get in any more of his underhanded
work without being caught at it.”
“That’s a capital scheme,” said the young Vermonter and finishing
his coffee he hurried to his room. There he secured his belt and
holster which he had tossed on his bed an hour previous. Also
before he left he rummaged through his traveling bag until he had
located a tiny electric pocket flash lamp which he had brought with
him all the way from Drueryville. Ten minutes later he was
sauntering down the single narrow street toward the power plant.
Darkness was just coming on as the sentries were changed and
the lad watched the small squad of regulars leave the barracks and
take their places at various points around the tiny village.
“I wonder,” mused the boy, “how many actually keep awake all
night? I’ll warrant half of them find some sheltered spot and go to
sleep after midnight.”
For an hour or two the little community resembled the quarry
towns of far off Vermont to such a degree that Jack actually became
a little homesick as he viewed the scene. Every cottage window
glowed with cheerful light and the day men, free from their tasks for
a while, were indulging in the only sociability Necaxa afforded: that
was to gather in twos and threes on cottage porches and spend the
evening in telling stories and smoking. Now and then some one of
these groups would burst forth in songs and what the tunes lacked
in harmony was made up for in the enthusiasm of the singers. Most
of the songs Jack recognized as having been popular back in the
States two years before.
At half past nine the groups began to dwindle, the men going off
to their various cottages. One by one the lights went out and by ten
o’clock the place was in total darkness, save for the lights in the
power plant. Jack felt very lonesome then. Except for the steady
grumble of the generators inside the big gray building, not a sound
disturbed the stillness. From place to place about the village the
youth roamed, peering here and there for signs of trouble. But
mostly he watched in the vicinity of the power plant.
This constant vigil was very tiresome, however, and several times
he paused in a secluded angle of the building and flashed his electric
lamp on the face of his watch. He was thoroughly glad when the
hands pointed out the hour of midnight.
He made one more tour of inspection after that, then started up
the street toward Mr. Ryder’s cottage. He had almost reached his
destination when suddenly his attention was attracted by a gray
shadow moving between two cottages some distance to his left. Jack
remembered that both buildings were occupied by Mexican linemen
and his suspicions were aroused immediately. As softly as a panther
he moved across the roadway and gained the corner of one of the
buildings. The shadow still lingered in the alley and the youth softly
slipped his revolver from its holster. But just as he was on the point
of calling to the man to throw up his hands he became aware of
another gray shadow moving about. This one was coming stealthily
up the roadway he had just left and Jack thanked his lucky stars that
he had hidden himself when he did.
It was quite evident to the Vermonter that the two shadows
intended to meet, but in order to accomplish this either one or the
other must pass within six feet of him. For a moment he scarcely
knew what to do, for he realized that he could not handle two men
at once.
The man in the alley had paused, but the one in the roadway
came forward softly and swiftly. When he was within fifteen feet of
the crouching youth Jack could see him quite distinctly. He wore a
very broad hat and the tight jacket of a rurale. Of a rurale! Instantly
the old Indian doctor’s story about a rurale with an injured foot
flashed upon him! This must be the man of the scarred heel!
Throwing all caution to the wind, Jack dropped his revolver and
leapt toward the shadowy figure. It was a perfect flying tackle and
the man came down with a crash, his legs pinned tightly together,
exactly as Jack had pinned the legs of many an opposing fullback on
the field at Drueryville.
The attack was so sudden that the man lay stunned for a moment.
Then as if he suddenly realized that it was a human being and not a
vice that had gripped him, the soldier began to struggle. He tried to
kick and squirm his way out of the boy’s arms, at the same time
thrashing about with his fists and cursing lustily in Spanish. He was a
big man and exceedingly powerful and Jack had all that he could do
to hold him on the ground.
The lad had the advantage, however, since the native was almost
flat on his stomach. By careful maneuvering and the help of two or
three wrestling holds that are known to every American boy he was
soon able to work himself astride the prostrated one and pin the
refractory hands down as well. This accomplished, the youth began
to shout for help at the top of his voice.
Mr. Ryder was first on the scene. He came running across from his
cottage, a revolver in one hand and an electric flash lamp in the
other. The Mexican linemen came tumbling out of their cottages a
few moments later and immediately after two Mexican regulars
arrived, all out of breath.
“Well, I think we’ve captured our man,” said Jack, panting in his
excitement. “Here, lay hold of this fellow, so I can stand up.”
The soldiers seized the prostrated one but they still kept him
pinned flat on his stomach, in spite of his protests.
“Mr. Ryder,” said Jack, “I think this is the man with the scarred
foot. Turn your light this way until we have a good look at his feet.
He hasn’t any boots on, that’s certain, for he moved about like a
cat.”
Hurriedly the engineer turned the light on the native’s naked feet
and there, standing out plainly in spite of the dirt and dust, was a
long scar that extended across the heel and partly up the side of his
foot toward the ankle. The wound looked exactly as if the man had
at one time stepped on a very sharp stone that had laid the flesh
open to the bone.
“By George, you’re right! He’s our man!” exclaimed the engineer
jubilantly. Then to the soldiers in Spanish he said:
“Hustle him off to the guardhouse, men, and put a double watch
over him, for he’s a traitor. I’ll pay a peso a day to the men who
watch him, but I’ll have the scoundrel shot who lets him get away.”
Without any ceremony the regulars jerked the big man to his feet
and marched him off down the street, Mr. Ryder and Jack following
directly behind with their revolvers cocked and ready for action. But
the heavy door to the prison pen had hardly been bolted behind the
rurale when the town was aroused by another sensation. From down
along the line of barbed wire fence came the sharp report of a rifle.
The first report was followed by two others in quick succession.
“What is it! An attack!” gasped Jack as he rushed forward with Mr.
Ryder. The sound of firing aroused every man in the camp and in an
instant half-clad soldiers and workmen came tumbling from barracks
hall and cottage.
“An attack! an attack!” was the cry they all uttered as they hurried
into the trenches.
But after the third shot the sentry’s guns were silent so long that
Mr. Ryder and Jack and Lieutenant Hernandez and Captain Alvarez
went to investigate.
“What was the trouble?” they demanded of the first soldier they
met.
“Shadows came along the fence. Three, four, five of them all came
to try and cut the wire. One dropped this,” said the sentry as he held
up an ugly looking machette.
“That’s mighty bad news,” said Mr. Ryder, “for it looks to me as if
the rebels are planning an attack. But we’ll fix these wire cutters to-
morrow night. In the meantime you fellows keep awake and on the
lookout until dawn.”
But when the news of the shadowy wire cutters was spread about
among the men there was little need for extra vigilance on the part
of the sentries, for every man in the village stayed up until daylight
discussing the possibilities of an attack. Indeed, the sun was just
rising as Jack and Mr. Ryder turned in for some much-needed sleep.
CHAPTER XV
IMPROVISED SEARCHLIGHTS
“Hi there, Jack, is that you?” called Mr. Ryder as the lad entered
the cottage.
“Yes, but what on earth are you doing here with all the rumpus
down at the plant?”
“Oh, I’ve been here for the last hour or more. To tell you the truth,
my boy, I did not have the heart to remain and see the outcome. I
knew the trap would work; in fact, I was afraid it would work too
well. How many men did they kill, Jack?” There was a note of
anxiety in the engineer’s voice as he asked the question.
“Three,” replied the boy.
“Well, thank heavens it wasn’t more,” said Mr. Ryder somewhat
relieved. “The riflemen would have had no compunction if the
number had been thirty-three, but I have. It seems wicked and
inhuman to sacrifice three lives in order to teach the beggars a
lesson. It makes me very unhappy.”
Jack was glad to find that Mr. Ryder took this attitude in the
matter. If the truth were known he had secretly felt a little bitter
toward the engineer for concocting such a diabolical trap. But when
he saw how unhappy it had made the man his bitterness turned to
sympathy.
“It does seem mighty hard to kill three men in order to teach the
rest of them a lesson, but I suppose it was absolutely necessary for
our own safety,” said the youth in an effort to relieve the engineer’s
feelings.
“You are quite right, my lad. It is hard, but it had to be done.
Sometimes, you know, the lesson is almost as disagreeable to the
teacher as it is to the pupil. I hope to goodness we’ll have no more
of this slaughter, but the way the rebels are acting I am very much
afraid that we will be in for a real battle before the trouble is settled.
I sincerely hope I’m wrong.”
The engineer was sitting at the table in the center of the room, a
mass of blueprints, drawings and typewritten data spread out in
front of him. His shirt was open at the throat, for the evening was
very warm and his revolver and cartridge belt had been removed
and tossed carelessly on the table before him.
“What are all the plans?” queried Jack as he sat down opposite
the engineer.
“These are the original sketches and preliminary drawings from
which I worked out my lightning arrester,” replied Mr. Ryder. “It
begins to look as if the stolen papers weren’t going to turn up. Our
rurale with the scarred foot denies all knowledge of their
whereabouts, which means that he will never tell where they are,
even if he does happen to know, for a Mexican can be mighty
stubborn when he feels disposed that way. Under the circumstances,
I fancy I’ll have to dig a new set of blueprints out of these old plans.
“And that isn’t going to be the easiest work in the world, let me
tell you. I have paid very little attention to the preliminary papers
since I worked out the final plans and the consequence is many of
the more important sketches and formulas have disappeared. I am
mighty sorry that I did not make duplicate drawings before I sent
the plans to Drueryville. The worst feature of the whole thing is the
fact that I have not yet applied for patent rights either in this
country or the United States. I could not take this step until I had
secured Dr. Moorland’s formula, you know, because that was one of
the fundamental features of the new appliance. In that case
whoever has the plans can very easily apply for patents in his own
name and then all my work will have been for nothing. Indeed, if I
wanted to use my own invention after that I would probably be
forced to pay a royalty to some one else. That would be a fine how-
de-do, wouldn’t it?”
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookgate.com