0% found this document useful (0 votes)
190 views58 pages

C in A Nutshell Second Edition Peter Prinz and Tony Crawford - Download The Ebook Now For The Best Reading Experience

The document promotes the ebook collection available at textbookfull.com, featuring various programming and legal texts, including 'C in a Nutshell' by Peter Prinz and Tony Crawford. It highlights the convenience of downloading ebooks in multiple formats for reading on any device. Additionally, it provides a detailed overview of the structure and content of 'C in a Nutshell,' which serves as a comprehensive reference for the C programming language based on the C11 standard.

Uploaded by

vyoralagulan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
190 views58 pages

C in A Nutshell Second Edition Peter Prinz and Tony Crawford - Download The Ebook Now For The Best Reading Experience

The document promotes the ebook collection available at textbookfull.com, featuring various programming and legal texts, including 'C in a Nutshell' by Peter Prinz and Tony Crawford. It highlights the convenience of downloading ebooks in multiple formats for reading on any device. Additionally, it provides a detailed overview of the structure and content of 'C in a Nutshell,' which serves as a comprehensive reference for the C programming language based on the C11 standard.

Uploaded by

vyoralagulan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Explore the full ebook collection and download it now at textbookfull.

com

C in a Nutshell Second Edition Peter Prinz And


Tony Crawford

https://textbookfull.com/product/c-in-a-nutshell-second-
edition-peter-prinz-and-tony-crawford/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

C# 9.0 in a Nutshell: The Definitive Reference 1st Edition


Joseph Albahari

https://textbookfull.com/product/c-9-0-in-a-nutshell-the-definitive-
reference-1st-edition-joseph-albahari/

textbookfull.com

C 7 0 in a Nutshell The Definitive Reference 7th Edition


Joseph Albahari

https://textbookfull.com/product/c-7-0-in-a-nutshell-the-definitive-
reference-7th-edition-joseph-albahari/

textbookfull.com

Sports Law in a Nutshell Fifth Edition Champion

https://textbookfull.com/product/sports-law-in-a-nutshell-fifth-
edition-champion/

textbookfull.com

International Taxation in a Nutshell Mindy Herzfeld

https://textbookfull.com/product/international-taxation-in-a-nutshell-
mindy-herzfeld/

textbookfull.com
Law School Success in a Nutshell Burkhart

https://textbookfull.com/product/law-school-success-in-a-nutshell-
burkhart/

textbookfull.com

Legal Writing and Analysis in a Nutshell Fifth Edition


Bahrych

https://textbookfull.com/product/legal-writing-and-analysis-in-a-
nutshell-fifth-edition-bahrych/

textbookfull.com

Paediatrics a Core Text on Child Health Second Edition


Tony Waterston

https://textbookfull.com/product/paediatrics-a-core-text-on-child-
health-second-edition-tony-waterston/

textbookfull.com

Falconry Basics A Handbook for Beginners Second Revised


Edition Tony Hall

https://textbookfull.com/product/falconry-basics-a-handbook-for-
beginners-second-revised-edition-tony-hall/

textbookfull.com

Gastrointestinal Emergencies 3rd Edition Tony C. K. Tham

https://textbookfull.com/product/gastrointestinal-emergencies-3rd-
edition-tony-c-k-tham/

textbookfull.com
C
in a Nutshell
Second Edition
Peter Prinz and Tony Crawford
C in a Nutshell, Second Edition
by Peter Prinz and Tony Crawford
Copyright © 2016 Peter Prinz and Tony Crawford. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA
95472.
O’Reilly books may be purchased for educational, business, or sales promotional use.
Online editions are also available for most titles (http://safaribooksonline.com). For more
information, contact our corporate/institutional sales department: 800-998-9938 or
[email protected].
Editors: Rachel Roumeliotis and
Katie Schooling

Production Editor: Kristen Brown

Copyeditor: Gillian McGarvey

Proofreader: Jasmine Kwityn

Indexer: Angela Howard

Interior Designer: David Futato

Cover Designer: Karen Montgomery

Illustrator: Rebecca Demarest

December 2005: First Edition

December 2015: Second Edition


Revision History for the Second Edition
2015-12-07: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781491904756 for release details.


The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. C in a Nutshell,
Second Edition, the cover image of a cow, and related trade dress are trademarks of
O’Reilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the
information and instructions contained in this work are accurate, the publisher and the
authors disclaim all responsibility for errors or omissions, including without limitation
responsibility for damages resulting from the use of or reliance on this work. Use of the
information and instructions contained in this work is at your own risk. If any code
samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that
your use thereof complies with such licenses and/or rights.
978-1-491-90475-6
[M]
Preface

This book is a complete reference to the C programming language and the C runtime
library. As an “In a Nutshell” book, its purpose is to serve as a convenient, reliable
companion for C programmers in their day-to-day work. It describes all the elements of
the language and illustrates their use with numerous examples.
The present description of the C language is based on the 2011 international C standard,
ISO/IEC 9899:2011, widely known as C11. This standard supersedes the C99 standard,
ISO/IEC 9899:1999, and its Technical Corrigenda, TC1 of 2001, TC2 of 2004, and TC3 of
2007. The first international C standard, ISO/IEC 9899:1990, was published in 1990 and
supplemented in 1995 by Normative Addendum 1 (ISO/IEC 9899/AMD1:1995). The
1990 ISO/IEC standard corresponds to the ANSI standard X3.159, which was ratified in
late 1989 and is commonly called ANSI C or C89.
The new features of the 2011 C standard are not yet fully supported by all compilers and
standard library implementations. In this book, we have therefore labeled 2011 features —
such as multithreading, type-generic macros, and new standard library functions — with
the abbreviation C11. Extensions that were introduced by the C99 standard are labeled
with the abbreviation C99.
This book is not an introduction to programming in C. Although it covers the
fundamentals of the language, it is not organized or written as a tutorial. If you are new to
C, we assume that you have read at least one of the many introductory books, or that you
are familiar with a related language, such as Java or C++.
How This Book Is Organized
This book is divided into three parts. The first part describes the C language in the strict
sense of the term; the second part describes the standard library; and the third part
describes the process of compiling and testing programs with the popular tools in the
GNU software collection.
Part I
Part I, which deals with the C language, includes Chapters 1 through 15. After Chapter 1,
which describes the general concepts and elements of the language, each chapter is
devoted to a specific topic, such as types, statements, or pointers. Although the topics are
ordered so that the fundamental concepts for each new topic have been presented in an
earlier chapter — types, for example, are described before expressions and operators,
which come before statements, and so on — you may sometimes need to follow references
to later chapters to fill in related details. For example, some discussion of pointers and
arrays is necessary in Chapter 5 (which covers expressions and operators), even though
pointers and arrays are not described in full detail until Chapters 8 and 9.
Chapter 1, “Language Basics”
Describes the characteristics of the language and how C programs are structured and
compiled. This chapter introduces basic concepts such as the translation unit,
character sets, and identifiers.
Chapter 2, “Types”
Provides an overview of types in C and describes the basic types, the type void, and
enumerated types.
Chapter 3, “Literals”
Describes numeric constants, character constants, and string literals, including escape
sequences.
Chapter 4, “Type Conversions”
Describes implicit and explicit type conversions, including integer promotion and the
usual arithmetic conversions.
Chapter 5, “Expressions and Operators”
Describes the evaluation of expressions, all the operators, and their compatible
operands.
Chapter 6, “Statements”
Describes C statements such as blocks, loops, and jumps.
Chapter 7, “Functions”
Describes function definitions and function calls, including recursive and inline
functions.
Chapter 8, “Arrays”
Describes fixed-length and variable-length arrays, including strings, array
initialization, and multidimensional arrays.
Chapter 9, “Pointers”
Describes the definition and use of pointers to objects and functions.
Chapter 10, “Structures, Unions, and Bit-Fields”
Describes the organization of data in these user-defined derived types.
Chapter 11, “Declarations”
Describes the general syntax of a declaration, identifier linkage, and the storage
duration of objects.
Chapter 12, “Dynamic Memory Management”
Describes the standard library’s dynamic memory management functions, illustrating
their use in a sample implementation of a generalized binary tree.
Chapter 13, “Input and Output”
Describes the C concept of input and output, with an overview of the use of the
standard I/O library.
Chapter 14, “Multithreading”
Describes the use of the C11 multithreading features, including atomic operations,
communication between threads, and thread-specific storage.
Chapter 15, “Preprocessing Directives”
Describes the definition and use of macros, conditional compiling, and all the other
preprocessor directives and operators.
Part II
Part II, consisting of Chapters 16, 17, and 18, is devoted to the C standard library. It
provides an overview of standard headers and also contains a detailed function reference.
Chapter 16, “The Standard Headers”
Describes contents of the headers and their use. The headers contain all of the
standard library’s macros and type definitions.
Chapter 17, “Functions at a Glance”
Provides an overview of the standard library functions, organized by areas of
application (e.g., mathematical functions, date and time functions, etc.).
Chapter 18, “Standard Library Functions”
Describes each standard library function in detail, in alphabetical order, and contains
examples to illustrate the use of each function.
Part III
The third part of this book, which includes Chapters 19 through 20, provides the necessary
knowledge of the C programmer’s basic tools: the compiler, the make utility, and the
debugger. The tools described here are those in the GNU software collection. Finally, the
use of these tools in an integrated development environment (IDE) for C is described
using the Eclipse IDE as an example.
Chapter 19, “Compiling with GCC”
Describes the principal capabilities that the widely used compiler offers for C
programmers.
Chapter 20, “Using make to Build C Programs”
Describes how to use the make program to automate the compiling process for large
programs.
Chapter 21, “Debugging C Programs with GDB”
Describes how to run a program under the control of the GNU debugger and how to
analyze programs’ runtime behavior to find logical errors.
Chapter 22, “Using an IDE with C”
Describes the use of an integrated development environment (IDE) for unified,
convienient access to all the tools for developing C programs.
Further Reading
In addition to works mentioned at appropriate points in the text, there are a number of
resources for readers who want more technical detail than even this book can provide. The
international working group on C standardization has an official home page at
http://www.open-std.org/jtc1/sc22/wg14, with links to the latest version of the C standard
and current projects of the working group.
For readers who are interested in not only the what and how of C, but also the why, the
WG14 site also offers links to some of its drafts and rationales. These documents describe
some of the motivations and constraints involved in the standardization process.
Furthermore, for those who may wonder how C “got to be that way” in the first place, the
originator of C, the late Dennis Ritchie, wrote an article titled “The Development of the C
Language”. This and other historical documents are still available on his Bell Labs
website, https://www.bell-labs.com/usr/dmr/www/index.html.
Readers who want details on floating-point math beyond the scope of C may wish to start
with David Goldberg’s thorough introduction, “What Every Computer Scientist Should
Know About Floating-Point Arithmetic,” currently available online at
http://docs.sun.com/source/806-3568/ncg_goldberg.html.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Highlights new terms; indicates filenames, file extensions, URLs, directories, and
Unix utilities.
Constant width

Indicates all elements of C source code: keywords, operators, variables, functions,


macros, types, parameters, and literals. Also used for console commands and options,
and the output from such commands.
Constant width bold

Highlights the function or statement under discussion in code examples. In compiler,


make, and debugger sessions, this font indicates command input to be typed literally
by the user.
Constant width italic

Indicates parameters in function prototypes, or placeholders to be replaced with your


own values.
Plain text
Indicates keys such as Return, Tab, and Ctrl.
TIP
This element signifies a tip or suggestion.

NOTE
This element signifies a general note.

WARNING
This element indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at
https://github.com/oreillymedia/c-in-a-nutshell-2E.
This book is here to help you get your job done. In general, if example code is offered
with this book, you may use it in your programs and documentation. You do not need to
contact us for permission unless you’re reproducing a significant portion of the code. For
example, writing a program that uses several chunks of code from this book does not
require permission. Selling or distributing a CD-ROM of examples from O’Reilly books
does require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “C in a Nutshell, 2nd Edition by Peter Prinz
and Tony Crawford (O’Reilly). Copyright 2016 Peter Prinz, Tony Crawford, 978-1-491-
90475-6.”
If you feel your use of code examples falls outside fair use or the permission given above,
feel free to contact us at [email protected].
Safari® Books Online
NOTE
Safari Books Online is an on-demand digital library that delivers expert content in both
book and video form from the world’s leading authors in technology and business.
Technology professionals, software developers, web designers, and business and creative
professionals use Safari Books Online as their primary resource for research, problem
solving, learning, and certification training.
Safari Books Online offers a range of plans and pricing for enterprise, government,
education, and individuals.
Members have access to thousands of books, training videos, and prepublication
manuscripts in one fully searchable database from publishers like O’Reilly Media,
Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que,
Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan
Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders,
McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more
information about Safari Books Online, please visit us online.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.

1005 Gravenstein Highway North

Sebastopol, CA 95472

800-998-9938 (in the United States or Canada)

707-829-0515 (international or local)

707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://bit.ly/C_Nutshell_2e.
To comment or ask technical questions about this book, send email to
[email protected].
For more information about our books, courses, conferences, and news, see our website at
http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
Both of us want to thank everyone at O’Reilly for their fantastic work on our book, and
especially our editors, Rachel Roumeliotis and Katie Schooling, for all their guidance
along the way. We also thank our technical reviewers, Matt Crawford, David Kitabjian,
Chris LaPre, John C. Craig, and Loïc Pefferkorn, for their valuable criticism of our
manuscript, and we’re grateful to our production editor, Kristen Brown, and our
copyeditor, Gillian McGarvey, for all their attention to making our book look good and
bringing our style up to date. Finally, thanks to Jonathan Gennick for setting the whole
project in motion all those years ago.
Peter
I would like to thank Tony, first of all, for the excellent collaboration. My heartfelt thanks
also go to all my friends for the understanding they showed again and again when I had so
little time for them. Last but not least, I dedicate this book to my daughters, Vivian and
Jeanette — both of them now PhDs in computer science — who strengthened my
ambition to carry out this book project.
Tony
I thank Peter for letting me take all the space I could fill in this project.
Part I. Language
Chapter 1. Language Basics

This chapter describes the basic characteristics and elements of the C programming
language.
Characteristics of C
C is a general-purpose, procedural programming language. Dennis Ritchie first devised C
in the 1970s at AT&T Bell Laboratories in Murray Hill, New Jersey, for the purpose of
implementing the Unix operating system and utilities with the greatest possible degree of
independence from specific hardware platforms. The key characteristics of the C language
are the qualities that made it suitable for that purpose:
Source code portability

The ability to operate “close to the machine”

Efficiency

As a result, the developers of Unix were able to write most of the operating system in C,
leaving only a minimum of system-specific hardware manipulation to be coded in
assembler.
C’s ancestors are the typeless programming languages BCPL (the Basic Combined
Programming Language), developed by Martin Richards; and B, a descendant of BCPL,
developed by Ken Thompson. A new feature of C was its variety of data types: characters,
numeric types, arrays, structures, and so on. Brian Kernighan and Dennis Ritchie
published an official description of the C programming language in 1978. As the first de
facto standard, their description is commonly referred to simply as K&R.1 C owes its high
degree of portability to a compact core language that contains few hardware-dependent
elements. For example, the C language proper has no file access or dynamic memory
management statements. In fact, there aren’t even any statements for console input and
output. Instead, the extensive C standard library provides the functions for all of these
purposes.
This language design makes the C compiler relatively compact and easy to port to new
systems. Furthermore, once the compiler is running on a new system, you can compile
most of the functions in the standard library with no further modification, because they are
in turn written in portable C. As a result, C compilers are available for practically every
computer system.
Because C was expressly designed for system programming, it is hardly surprising that
one of its major uses today is in programming embedded systems. At the same time,
however, many developers use C as a portable, structured high-level language to write
programs such as powerful word processor, database, and graphics applications.
The Structure of C Programs
The procedural building blocks of a C program are functions, which can invoke one
another. Every function in a well-designed program serves a specific purpose. The
functions contain statements for the program to execute sequentially, and statements can
also be grouped to form block statements, or blocks. As the programmer, you can use the
ready-made functions in the standard library, or write your own when no standard function
fulfills your intended purpose. In addition to the C standard library, there are many
specialized libraries available, such as libraries of graphics functions. However, by using
such nonstandard libraries, you limit the portability of your program to those systems to
which the libraries themselves have been ported.
Every C program must define at least one function of its own, with the special name
main(), which is the first function invoked when the program starts. The main() function
is the program’s top level of control, and can call other functions as subroutines.
Example 1-1 shows the structure of a simple, complete C program. We will discuss the
details of declarations, function calls, output streams, and more elsewhere in this book.
For now, we are simply concerned with the general structure of the C source code. The
program in Example 1-1 defines two functions, main() and circularArea(). The main()
function calls circularArea() to obtain the area of a circle with a given radius, and then
calls the standard library function printf() to output the results in formatted strings on
the console.
Example 1-1. A simple C program
// circle.c: Calculate and print the areas of circles

#include <stdio.h> // Preprocessor directive

double circularArea( double r ); // Function declaration (prototype form)

int main() // Definition of main() begins


{
double radius = 1.0, area = 0.0;

printf( " Areas of Circles\n\n" );


printf( " Radius Area\n"
"-------------------------\n" );

area = circularArea( radius );


printf( "%10.1f %10.2f\n", radius, area );

radius = 5.0;
area = circularArea( radius );
printf( "%10.1f %10.2f\n", radius, area );

return 0;
}

// The function circularArea() calculates the area of a circle


// Parameter: The radius of the circle
// Return value: The area of the circle

double circularArea( double r ) // Definition of circularArea() begins


{
const double pi = 3.1415926536; // Pi is a constant
return pi * r * r;
}
Output:

Areas of Circles

Radius Area
-------------------------
1.0 3.14
5.0 78.54

Note that the compiler requires a prior declaration of each function called. The prototype
of circularArea() in the third line of Example 1-1 provides the information needed to
compile a statement that calls this function. The prototypes of standard library functions
are found in standard header files. Because the header file stdio.h contains the prototype of
the printf() function, the preprocessor directive #include <stdio.h> declares the
function indirectly by directing the compiler’s preprocessor to insert the contents of that
file. (See also “How the C Compiler Works”.)
You may arrange the functions defined in a program in any order. In Example 1-1, we
could just as well have placed the function circularArea() before the function main(). If
we had, then the prototype declaration of circularArea() would be superfluous, because
the definition of the function is also a declaration.
Function definitions cannot be nested inside one another: you can define a local variable
within a function block, but not a local function.
Source Files
The function definitions, global declarations, and preprocessing directives make up the
source code of a C program. For small programs, the source code is written in a single
source file. Larger C programs consist of several source files. Because the function
definitions generally depend on preprocessor directives and global declarations, source
files usually have the following internal structure:
1. Preprocessor directives

2. Global declarations

3. Function definitions

C supports modular programming by allowing you to organize a program in as many


source and header files as desired, and to edit and compile them separately. Each source
file generally contains functions that are logically related, such as the program’s user
interface functions. It is customary to label C source files with the filename suffix .c.
Examples 1-2 and 1-3 show the same program as Example 1-1, but divided into two
source files.
Example 1-2. The first source file, containing the main() function
// circle.c: Prints the areas of circles.
// Uses circulararea.c for the math

#include <stdio.h>
double circularArea( double r );

int main()
{
/* ... As in Example 1-1… */
}

Example 1-3. The second source file, containing the circularArea() function
// circulararea.c: Calculates the areas of circles.
// Called by main() in circle.c

double circularArea( double r )


{
/* ... As in Example 1-1… */
}

When a program consists of several source files, you need to declare the same functions
and global variables, and define the same macros and constants, in many of the files.
These declarations and definitions thus form a sort of file header that is more or less
constant throughout a program. For the sake of simplicity and consistency, you can write
this information just once in a separate header file, and then reference the header file using
an #include directive in each source code file. Header files are customarily identified by
the filename suffix .h. A header file explicitly included in a C source file may in turn
include other files.
Each C source file, together with all the header files included in it, makes up a translation
unit. The compiler processes the contents of the translation unit sequentially, parsing the
source code into tokens, its smallest semantic units, such as variable names and operators.
See “Tokens” for more detail.
Any number of whitespace characters can occur between two successive tokens, allowing
you a great deal of freedom in formatting the source code. There are no rules for line
breaks or indenting, and you may use spaces, tabs, and blank lines liberally to create
“human-readable” source code. The preprocessor directives are slightly less flexible: a
preprocessor directive must always appear on a line by itself, and no characters except
spaces or tabs may precede the hash mark (#) that begins the line.
There are many different conventions and “house styles” for source code formatting. Most
of them include the following common rules:
Start a new line for each new declaration and statement.

Use indentation to reflect the nested structure of block statements.


Exploring the Variety of Random
Documents with Different Content
“From our Camp, 16th September, 1745.
“Being now in a condition to make our way into the capital of his
majesty’s ancient kingdom of Scotland, we hereby summon you to
receive us, as you are in duty bound to do; and in order to it, we
hereby require you, upon receipt of this, to summon the town-
council and take proper measures for securing the peace and quiet
of the city, which we are very desirous to protect. But if you suffer
any of the usurper’s troops to enter the town, or any of the cannon,
arms, or ammunition in it, (whether belonging to the public or
private persons,) to be carried off, we shall take it as a breach of
your duty, and a heinous offence against the king and us, and shall
resent it accordingly. We promise to preserve all the rights and
liberties of the city, and the particular property of every one of his
majesty’s subjects. But if any opposition be made to us, we cannot
answer for the consequences, being firmly resolved at any rate to
enter the city; and in that case, if any of the inhabitants are found in
arms against us, they must not expect to be treated as prisoners of
war.”

After this letter was read, the clamour for surrender became more
loud and general than ever, and, agreeably to the wish of the
meeting, a deputation, consisting of four members of the council,
was appointed to wait upon the prince immediately, and to request
that he would grant the citizens time to deliberate on the contents of
his letter.
While the meeting was debating the question as to the reading of
Charles’s letter, an incident occurred, which, it is believed, gave the
finishing stroke to the mock heroism of the volunteers. After the
retreat of the dragoons, the volunteers had assembled, on the
ringing of the fire-bell, at their respective posts, to be in readiness to
obey any instructions which might be sent to them. Four companies,
out of the six, were drawn up in the Lawnmarket between four and
five o’clock in the afternoon, but before they had sufficient time to
recover from the agitation into which they had been thrown by the
call to arms, a well-dressed person, unknown to those assembled,
entered the Lawnmarket from the West-Bow, in great haste,
mounted upon a grey horse, and galloping along the lines of the
volunteers, intimated, in a voice sufficiently high to be heard by the
astonished volunteers, that he had seen the Highland army, and that
it amounted to 16,000 men! This “lying messenger did not stop to
be questioned, and disappeared in a moment.”[894] Captain
Drummond, soon after this occurrence, arrived upon the spot, and,
after consulting with his brother officers, marched up the four
companies to the castle, where they delivered up their arms. In a
short time the other companies also went up and surrendered their
arms, and were followed by the other bodies of militia that had
received arms from the castle magazine.
About eight o’clock at night, the four deputies left the city to wait
upon the prince at Gray’s Mill; but they had scarcely cleared the
walls, when intelligence was received by the lord provost and
magistrates, (who still remained assembled in the council-chamber,)
that the transports with General Cope’s army on board had arrived
off Dunbar, about 27 miles east from Edinburgh, and that as the
wind was unfavourable for bringing them up the Frith, Cope
intended to land his troops at Dunbar and march to the relief of the
city. As this intelligence altered the aspect of affairs, messengers
were immediately despatched to bring back the deputies before they
should reach their destination, but they did not overtake them. The
deputies returned to the city about ten o’clock, and brought along
with them a letter of the following tenor, signed by Secretary
Murray:—
“His royal highness the prince regent thinks his manifesto, and the
king his father’s declaration, already published, a sufficient
capitulation for all his majesty’s subjects to accept with joy. His
present demands are, to be received into the city as the son and
representative of the king his father, and obeyed as such when
there. His royal highness supposes, that since the receipt of his letter
to the provost no arms or ammunition have been suffered to be
carried off or concealed, and will expect a particular account of all
things of that nature. Lastly, he expects a positive answer before two
o’clock in the morning, otherwise he will think himself obliged to
take measures conform.”
This letter gave rise to a lengthened discussion in the town-
council, which ended in a resolution to send out a second deputation
to the prince, and, under the pretence of consulting the citizens, to
solicit a few hours’ delay. The deputies accordingly set out in a coach
to the prince’s head-quarters at two o’clock in the morning, and had
an interview with Lord George Murray, whom they prevailed upon to
second their application for delay. His lordship went into the prince’s
apartment, and one of the deputies overheard him endeavouring to
persuade Charles to agree to the request made by them, but the
prince refused. Lord George having reported the failure of his
attempt to the deputies, was induced by them to return and make
another trial, but he was again unsuccessful. Charles then requested
that the deputies should be ordered away, and being offended at
Lord George Murray’s entreaties, desired Lord Elcho, the son of the
Earl of Wemyss, who had just joined him, to intimate the order to
them, which he accordingly did.[895]
Apprehensive of the speedy arrival of Cope, Charles resolved not
to lose a moment in obtaining possession of the capital. He saw that
no effectual resistance could be made by the inhabitants in case of
an assault; but as opposition might exasperate the Highlanders, and
make them regardless of the lives of the citizens, he proposed to his
officers that an attempt should be made to carry the city by surprise,
which, if successful, would save it from the horrors which usually
befall a city taken by storm. The plan of a surprise having been
resolved upon, a select detachment of about 900 men, under
Lochiel, Keppoch, Ardshiel, and O’Sullivan, was sent under cloud of
night towards the city. They marched with great secrecy across the
Borough moor, and reached the south-eastern extremity of the city,
where they halted. A party of 24 men was thereupon despatched
with directions to post themselves on each side of the Netherbow
Port, the eastern or lower gate of the city, and another party of 60
men was directed to follow them half-way up St. Mary’s Wynd, to be
ready to support them, while a third body, still farther removed, and
finally the remainder of the detachment, were to come up in
succession to the support of the rest. In the event of these
dispositions succeeding without observation from the sentinels on
the walls, it had been arranged that a Highlander in a lowland garb
should knock at the wicket and demand entrance as a servant of an
officer of dragoons, who had been sent by his master to bring him
something he had forgot in the city; and that if the wicket was
opened, the party stationed on each side of the gate should
immediately rush in, seize the guard, and make themselves masters
of the gate. The different parties having taken the stations assigned
them without being perceived by the guards, the disguised
Highlander knocked at the gate and stated his pretended errand; but
the guard refused to open the gate, and the sentinels on the walls
threatened to fire upon the applicant if he did not instantly retire.
The commanders were puzzled by this unexpected refusal, and were
at a loss how to act. It was now near five o’clock, and the morning
was about to dawn. The alternative of an assault seemed inevitable,
but fortunately for the city, the Highlanders were destined to obtain
by accident what they could not effect by stratagem.[896]
While the party at the gate was about to retire to the main body in
consequence of the disappointment they had met with, their
attention was attracted by the rattling of a carriage, which, from the
increasing sound, appeared to be coming down the High-street
towards the Netherbow Port. It was, in fact, the hackney coach
which had been hired by the deputies, which was now on its way
back to the Canongate, where most of the proprietors of hackney
coaches at that time lived. The Highlanders stationed at the gate
stood prepared to enter, and as soon as it was opened to let out the
coach, the whole party, headed by Captain Evan Macgregor, a
younger son of Macgregor of Glencairnaig, rushed in, made
themselves masters of the gate, and disarmed the guard in an
instant. In a short time the whole of the Highlanders followed, with
drawn swords and targets, and setting up one of those hideous and
terrific yells with which they salute an enemy they are about to
encounter, marched quickly up the street in perfect order, in
expectation of meeting the foe;[897] but to the surprise, no less than
the pleasure, of the Highlanders, not a single armed man was to be
seen in the street. With the exception of a few half-awakened
spectators, who, roused from their slumbers by the shouts of the
Highlanders, had jumped out of bed, and were to be seen peeping
out at the windows in their sleeping habiliments, all the rest of the
inhabitants were sunk in profound repose.
Having secured the guard-house and disarmed the guards who
were within, the Highlanders took possession of the different gates
of the city and of the stations upon the walls. They made the guards
prisoners, and replaced them with some of their own men, with as
much quietness as if they had been merely changing their own
guard.[898] The Highlanders conducted themselves on this occasion
with the greatest order and regularity, no violence being offered to
any of the inhabitants, and the utmost respect being paid to private
property.
Anxious about the result, Charles had slept only two hours, and
that without taking off his clothes. At an early hour he received
intelligence of the capture of the city, and immediately prepared to
march towards it with the rest of the army. To avoid the castle guns,
the prince took a circuitous direction to the south of the city, till he
reached the Braid burn, when, turning towards the city, he marched
as far as the Buck Stone,[899] a mass of granite on the side of the
turnpike road, near Morningside. On reaching this stone, he drew off
his army by a solitary cross road, leading to the ground now
occupied by Causewayside and Newington. Arrived near Priestfield,
he entered the king’s park by a breach, which had been made in the
wall, and proceeded to the Hunter’s bog, a deep valley between
Arthur’s Seat and Salisbury Crags, where his army was completely
sheltered from the guns of the castle.[900]
Charles was now within the royal domains, and little more than a
quarter of a mile from the royal palace of Holyrood, where his
grandfather, James II., when Duke of York, had, about 60 years
before, exercised the functions of royalty, as the representative of
his brother Charles II. Sanguine as he was, he could scarcely have
imagined that within the space of one short month, from the time he
had raised his standard in the distant vale of the Finnan, he was to
obtain possession of the capital of Scotland, and take up his
residence in the ancient abode of his royal ancestors. Exulting as he
must have done, at the near prospect which such fortuitous events
seemed to afford him of realizing his most ardent expectations, his
feelings received a new impulse, when, on coming within sight of the
palace, he beheld the park crowded with people, who had
assembled to welcome his arrival. Attended by the Duke of Perth
and Lord Elcho, and followed by a train of gentlemen, Charles rode
down the Hunter’s bog, on his way to the palace. On reaching the
eminence below St. Anthony’s well, he alighted from his horse for
the purpose of descending on foot into the park below. On
dismounting he was surrounded by many persons who knelt down
and kissed his hand. He made suitable acknowledgments for these
marks of attachment, and after surveying for a short time the palace
and the assembled multitude which covered the intervening
grounds, he descended into the park below amid the shouts of the
spectators, whose congratulations he received with the greatest
affability. On reaching the foot-path in the park, which, from its
having been much frequented by the Duke of York, afterwards
James II., when he resided at Holyrood, obtained the name of the
Duke’s walk, Charles stopped for a few minutes to exhibit himself to
the people.[901]
In person Charles appeared to great advantage. His figure and
presence are described by Mr. Home, an eye-witness, as not ill-
suited to his lofty pretensions. He was in the bloom of youth, tall[902]
and handsome, and of a fair and ruddy complexion. His face, which
in its contour exhibited a perfect oval, was remarkable for the
regularity of its features. His forehead was full and high, and
characteristic of his family. His eyes, which were large, and of a light
blue colour, were shaded by beautifully arched eye-brows, and his
nose, which was finely formed, approached nearer to the Roman
than the Grecian model. A pointed chin, and a mouth rather small,
gave him, however, rather an effeminate appearance; but on the
whole, his exterior was extremely prepossessing, and his deportment
was so graceful and winning, that few persons could resist his
attractions. The dress which he wore on the present occasion was
also calculated to set off the graces of his person to the greatest
advantage in the eyes of the vulgar. He wore a light-coloured
peruke, with his hair combed over the front. This was surmounted
by a blue velvet bonnet, encircled with a band of gold lace, and
ornamented at top with a Jacobite badge, a white satin cockade. He
wore a tartan short coat, and on his breast the star of the order of
St. Andrew. Instead of a plaid, which would have covered the star,
he wore a blue sash wrought with gold. His small clothes were of red
velvet. To complete his costume, he wore a pair of military boots,
and a silver-hilted broadsword.[903]
Charles remained some time in the park among the people, but as
he could not be sufficiently seen by all, he mounted his horse, a fine
bay gelding which the Duke of Perth had presented to him, and rode
off slowly towards the palace. Every person was in admiration at the
splendid appearance he made on horseback, and a simultaneous
huzza arose from the vast crowd which followed the prince in
triumph to Holyrood House. Overjoyed at the noble appearance of
the prince, the Jacobites set no bounds to their praises of the royal
youth. They compared him to King Robert Bruce, whom, they said,
he resembled in his figure as they hoped he would in his fortune.[904]
The Whigs, on the other hand, regarded him differently; and though
they durst not avow their opinions to the full extent, and were
forced to admit that Charles was a goodly person, yet they observed
that even in that triumphant hour when about to enter the palace of
his fathers, the air of his countenance was languid and melancholy,
—that he looked like a gentleman and a man of fashion, but not like
a hero or a conqueror. Their conclusion was, that the enterprise he
had undertaken was above the pitch of his mind, and that his heart
was not great enough for the sphere in which he moved.[905]
Holyrood House in 1745. From an old print.
On arriving in front of the palace Charles alighted from his horse,
and entering the gate proceeded along the piazza within the
quadrangle, towards the Duke of Hamilton’s apartments.[906] When
the prince was about to enter the porch, the door of which stood
open to receive him, a gentleman stepped out of the crowd, drew
his sword, and raising it aloft, walked up stairs before Charles. The
person who took this singular mode of joining the prince, was James
Hepburn of Keith, a gentleman of East Lothian. When a very young
man he had been engaged in the rebellion of 1715, not from any
devoted attachment to the house of Stuart, (for he disclaimed the
hereditary indefeasible right of kings, and condemned the
government of James II.,) but because he considered the union,
which he regarded as the result of the revolution, as injurious and
humiliating to Scotland, and believed that the only way to obtain a
repeal of that measure, was to restore the Stuarts. In speaking of
the union, he said that it had made a Scottish gentleman of small
fortune nobody, and that rather than submit to it, he would die a
thousand deaths. For thirty years he had kept himself in readiness to
take up arms to assert, as he thought, the independence of his
country, when an opportunity should occur. Honoured and beloved
by both Jacobites and Whigs, the accession to the Jacobite cause of
this accomplished gentleman, whom Mr. Home describes as a model
of ancient simplicity, manliness, and honour, was hailed by the
former with delight, and deeply regretted by the latter, who
lamented that a man whom they so highly revered, should sacrifice
himself to the visionary idea of a repeal of the union between
England and Scotland.[907]
On his way to the palace Charles had been cheered by the
acclamations of the people; and on his entering that memorable seat
of his ancestors, these acclamations were redoubled by the crowd
which filled the area in front. On reaching the suite of apartments
destined for his reception, he exhibited himself again to the people
from one of the windows with his bonnet in his hand, and was
greeted with loud huzzas by the multitude assembled in the
courtyard below. He replied to these congratulations by repeated
bows and smiles.
To complete the business of this eventful day, the proclamation at
the cross of the Chevalier de St. George as James III., alone
remained. The Highlanders who entered the city in the morning,
desirous of obtaining the services of the heralds and the pursuivants,
to perform what appeared to them an indispensable ceremony, had
secured the persons of these functionaries. Surrounded by a body of
armed men, the heralds and pursuivants, several of whom had
probably been similarly employed on the accession of “the Elector of
Hanover,” proceeded to the cross, a little before one o’clock
afternoon, clothed in their robes of office, and proclaimed King
James, amid the general acclamations of the people. The windows of
the adjoining houses were filled with ladies, who testified the
intensity of their feelings by straining their voices to the utmost
pitch, and with outstretched arms waving white handkerchiefs in
honour of the handsome young adventurer. Few gentlemen were,
however, to be seen in the streets or at the windows, and even
among the common people, there were not a few who preserved a
stubborn silence.[908] The effect of the ceremony was greatly
heightened by the appearance of Mrs. Murray of Broughton, a lady
of great beauty, who, to show her devoted attachment to the cause
of the Stuarts, decorated with a profusion of white ribbons, sat on
horseback near the cross with a drawn sword in her hand, during all
the time the ceremony lasted.[909]
While the heralds were proclaiming King James at the market-
cross of Edinburgh, Sir John Cope, who, as has been stated, arrived
in the mouth of the Frith of Forth on the 16th, was landing his
troops at Dunbar. The two regiments of dragoons had continued
their inglorious flight during the night, and had reached that town,
on the morning of the 17th, “in a condition,” to use the soft
expression of Mr. Home, “not very respectable.” On arriving at
Musselburgh, they had halted for a short time, and afterwards went
to a field between Preston Grange and Dolphinston, where they
dismounted for the purpose of passing the night; but between ten
and eleven o’clock they were aroused by the cries of a dragoon who
had fallen into an old coal-pit full of water. Conceiving that the
Highlanders were at hand, they instantly mounted their horses and
fled towards Dunbar with such precipitation and alarm, that they
dropped their arms by the way. Next morning the road to Dunbar
was found strewed with the swords, pistols, and firelocks, which had
fallen from the nervous hands of these cowards. Colonel Gardiner,
who had slept during the night in his own house at Preston, near the
field where the dragoons were to bivouack, was surprised, when he
rose in the morning, to find that his men were all gone. All that he
could learn was that they had taken the road to Dunbar. He followed
them with a heavy heart, which certainly did not lighten when he
saw the proofs they had left behind them of their pusillanimity.
These arms were collected and conveyed in covered carts to Dunbar,
where they were again put into the hands of the craven dragoons.
[910]
The landing of Cope’s troops was finished on Wednesday, the 17th
of September; but the disembarkation of the artillery and stores was
not completed till the 18th. On the last-mentioned day, Mr. Home,
the author of the history of this Rebellion, arrived at Dunbar, and
was introduced to Sir John, as a “volunteer from Edinburgh,”
desirous of communicating to him such information as he had
personally collected respecting the Highland army. He told the
general, that being curious to see the Highland army and its leader,
and to ascertain the number of the Highlanders, he had remained in
Edinburgh after they had taken possession thereof,—that for the
last-mentioned purpose, he had visited the different parts they
occupied in the city, and had succeeded in making a pretty exact
enumeration,—that with the same view he had perambulated the
Hunter’s bog, where the main body was encamped,—and as he
found the Highlanders sitting in ranks upon the ground taking a
meal, that he was enabled to calculate their numbers with great
certainty. He stated, from the observations he had been thus
enabled to make, that the whole Highlanders within and without the
city did not amount to 2,000 men; but that he had been told that
several bodies of men from the north were on their march, and were
expected very soon to join the main body at Edinburgh. In answer to
a question put by Cope, as to the appearance and equipment of the
Highlanders, Home stated that most of them seemed to be strong,
active, and hardy men, though many of them were of a very
ordinary size: and if clothed like Lowlanders, would, in his opinion,
appear inferior to the king’s troops; but the Highland garb favoured
them much, as it showed their naked limbs, which were strong and
muscular; and their stern countenances and bushy uncombed hair
gave them a fierce, barbarous, and imposing aspect. With regard to
their arms, Mr. Home said that they had no artillery of any sort but
one small unmounted iron cannon, lying upon a cart, drawn by a
little Highland pony,—that about 1,400 or 1,500 of them were armed
with firelocks and broadswords,—that their firelocks were of all sorts
and sizes, consisting of muskets, fusees, and fowling pieces,—that
some of the rest had firelocks without swords, while others had
swords without firelocks,—that many of their swords were not
Highland broadswords but French,—that one or two companies,
amounting to about 100 men, were armed, each of them with the
shaft of a pitch-fork, with the blade of a scythe fastened to it,
resembling in some degree the Lochaber axe. Mr. Home, however,
added, that all the Highlanders would soon be provided with
firelocks, as the arms belonging to the train bands of the city had
fallen into their hands.[911]
At Dunbar, General Cope was joined by some judges and lawyers,
who had fled from Edinburgh on the approach of the Highlanders.
They did not, however, enter the camp as fighting men, but with the
intention of continuing with the king’s army, as anxious and
interested spectators of the approaching conflict. Cope found a more
efficient supporter in the person of the Earl of Home, then an officer
in the guards, who considered it his duty to offer his services on the
present occasion. Unlike his ancestors, who could have raised in
their own territories a force almost equal to that now opposed to Sir
John Cope, this peer was attended by one or two servants only, a
circumstance which gave occasion to many persons to mark the
great change in the feudal system which had taken place in
Scotland, in little more than a century.
Desirous of engaging the Highland army before the arrival of its
expected reinforcements, General Cope left Dunbar on the 19th of
September, in the direction of Edinburgh. The cavalry, infantry,
cannon, and baggage-carts, which extended several miles along the
road, gave a formidable appearance to this little army, and attracted
the notice of the country people, who, having been long
unaccustomed to war and arms, flocked from all quarters to see an
army on the eve of battle; and with infinite concern and anxiety for
the result beheld the uncommon spectacle. The army halted on a
field to the west of the town of Haddington, sixteen miles east from
Edinburgh. As it was supposed that the Highlanders might march in
the night time, and by their rapid movements surprise the army, a
proposal was made in the evening, to the general, to employ some
of the young men who followed the camp, to ride betwixt
Haddington and Duddingston, during the night, so as to prevent
surprise. This proposal was approved of by Cope, and sixteen young
men, most of whom had been volunteers at Edinburgh, offered their
services. These were divided into two parties of eight men each; one
of which, subdivided into four parties of two men each, set out at
nine o’clock at night, by four different roads that led to Duddingston.
These parties returned to the camp at midnight, and made a report
to the officer commanding the piquet, that they had not met with
any appearance of the enemy. The other party then went off,
subdivided as before, by the different routes, and rode about till day-
break, when six of them returned and made a similar report, but the
remaining two who had taken the coast road to Musselburgh, did
not make their appearance at the camp, having been made prisoners
by an attorney’s apprentice, who conducted them to the rebel camp
at Duddingston! The extraordinary capture of these doughty
patroles, one of whom was Francis Garden, afterwards better known
as a lord of session, by the title of Lord Gardenstone, and the other
Mr. Robert Cunningham, known afterwards as General Cunningham,
is thus humorously detailed by a writer in the Quarterly Review:—
“The general sent two of the volunteers who chanced to be
mounted, and knew the country, to observe the coast road,
especially towards Musselburgh. They rode on their exploratory
expedition, and coming to that village, which is about six miles from
Edinburgh, avoided the bridge to escape detection, and crossed the
Esk, it being then low water, at a place nigh its junction with the sea.
Unluckily there was at the opposite side a snug thatched tavern,
kept by a cleanly old woman called Luckie F——, who was eminent
for the excellence of her oysters and sherry. The patroles were both
bon-vivants; one of them whom we remember in the situation of a
senator, as it is called, of the college of justice, was unusually so,
and a gay witty agreeable companion besides. Luckie’s sign and the
heap of shells deposited near her door, proved as great a temptation
to this vigilant forlorn-hope, as the wine-house to the abbess of
Andonillet’s muleteer. They had scarcely got settled at some right
Pandores, with a bottle of sherry as an accompaniment, when, as
some Jacobite devil would have it, an unlucky north-country lad, a
writer’s (i.e. attorney’s) apprentice, who had given his indentures the
slip, and taken the white-cockade, chanced to pass by on his errand
to join Prince Charlie. He saw the two volunteers through the
window, knew them, and guessed their business; he saw the tide
would make it impossible for them to return along the sands as they
had come. He therefore placed himself in ambush upon the steep,
narrow, impracticable bridge, which was then, and for many years
afterwards, the only place of crossing the Esk, ‘and how he contrived
it,’ our narrator used to proceed, ‘I never could learn, but the
courage and assurance of the province from which he came are
proverbial. In short, the Norland whipper-snapper surrounded and
made prisoners of my two poor friends, before they could draw a
trigger.’”[912]
Cope resumed his march on the morning of the 20th of
September, following the course of the post road to Edinburgh, till he
came near Haddington, when he led off his army along another
road, nearer the coast, by St. Germains and Seaton. His object in
leaving the post road was to avoid some defiles and inclosures which
would have hindered, in case of attack, the operations of his cavalry.
In its march the army was followed by a number of spectators, all
anxious to witness the expected combat; but they were assured by
the officers that as the army was now rendered complete by the
junction of the horse and foot, the Highlanders would not venture to
engage. As some persons who ventured to express a different
opinion were looked upon with jealousy, it is not improbable that the
officers who thus expressed themselves did not speak their real
sentiments.
On leaving the post road the general sent forward the Earl of
Loudon his adjutant-general, with Lord Home and the quarter-
master-general, to select ground near Musselburgh, on which to
encamp the army during the night; but this party had not proceeded
far when they observed some straggling parties of Highlanders
advancing. The Earl of Loudon immediately rode back at a good
pace, and gave Sir John the information just as the van of the royal
army was entering the plain betwixt Seaton and Preston, known by
the name of Gladsmuir. Judging the ground before him a very
eligible spot for meeting the Highlanders, the general continued his
march along the high road to Preston, and halted his army on the
moor, where he formed his troops in order of battle, with his front to
the west. His right extended towards the sea in the direction of Port
Seaton, and his left towards the village of Preston. These
dispositions had scarcely been made when the whole of the
Highland army appeared.
The disembarkation of the royal army, and the advance of Cope
towards Edinburgh, were known to Charles in the course of
Thursday the 19th. Judging it of importance that no time should be
lost in meeting Cope and bringing him to action, Charles had left
Holyrood house on the evening of that day, and had proceeded to
Duddingston, near which place his army was encamped. Having
assembled a council of war, he proposed to march next morning and
give battle to Sir John Cope. The members of the council having
signified their acquiescence, the prince then asked the Highland
chiefs how they thought their men would conduct themselves on
meeting a commander who had at last mustered courage to meet
them. As Macdonald of Keppoch had served in the French army, and
was considered, on that account, to be a fit judge of what the
Highlanders could do against regular troops, he was desired by the
other chiefs to give his opinion. Keppoch observed that as the
country had been long at peace, few or none of the private men had
ever seen a battle, and that it was not therefore very easy to form
an opinion as to how they would behave; but that he would venture
to assure his royal highness that the gentlemen of the army would
be in the midst of the enemy, and that as the clans loved both the
cause and their chiefs, they would certainly share the danger with
their leaders. Charles thereupon declared that he would lead on the
Highlanders himself, and charge at their head; but the chiefs
checked his impetuosity by pointing out the ruin that would befall
them if he perished in the field, though his army should be
successful. They declared that, should he persist in his resolution,
they would return home and make the best terms they could for
themselves. This remonstrance had the desired effect upon the
young Chevalier, who agreed to take a post of less danger.[913]
According to the calculation of Home, which has been alluded to,
the Highland army, at the date of the capture of Edinburgh, did not
exceed 2,000 men; but it was increased by about 400 more, by a
party of 150 Maclauchlans who joined it on the 18th, and by an
accession of 250 Athole-men on the following day. This force was
further augmented by the Grants of Glenmoriston, who joined the
army at Duddingston on the morning of Friday the 20th. In
pursuance of the resolution of the council, the prince put himself at
the head of his army on that morning, and presenting his sword,
exclaimed, “My friends, I have flung away the scabbard!”[914] This
was answered by a loud huzza, on which the army marched forward
in one column of three files or ranks towards Musselburgh. Passing
the Esk by the bridge of Musselburgh, the army proceeded along the
post road towards Pinkie. On arriving opposite the south side of
Pinkie gardens, Lord George Murray, who led the van, received
information that Sir John Cope was at or near Preston, and that his
intention probably was to gain the high grounds of Fawside near
Carberry. As there was no time to deliberate or wait for orders, and
as Lord George, who was very well acquainted with these grounds,
considered the occupation of them by the Highlanders as of great
importance; he struck off to the right at Edgebuckling Brae, and
passing through the fields by the west side of Wallyford, gained the
eminence in less than half an hour, where he waited for the rear.[915]
From Fawside hill the prince descried the army of Cope drawn up
in the manner before described, but its position being different from
that anticipated, Charles drew off his army towards the left, and
descending the hill in the direction of Tranent, entered again upon
the post road at some distance to the west of the village, along
which he continued his march. On approaching Tranent the
Highlanders were received by the king’s troops with a vehement
shout of defiance, which the Highlanders answered in a similar
strain. About two o’clock in the afternoon the Highland army halted
on an eminence called Birsley Brae, about half a mile to the west of
Tranent, and formed in order of battle about a mile from the royal
forces.
In the expectation that the Highlanders were advancing by the
usual route through Musselburgh, Cope had taken up the position
we have described with his front to the west; but as soon as he
observed the Highlanders on the heights upon his left he changed
his front to the south. This change of position, while it secured Cope
better from attack, was not so well calculated for safety as the first
position was in the event of a defeat. On his right was the east wall
of a park, belonging to Erskine of Grange, which extended a
considerable way from north to south, and still farther to the right
was the village of Preston. The village of Seaton was on his left, and
the village of Cockenzie and the sea in his rear. Almost immediately
in front was a deep ditch filled with water, and a strong and thick
hedge. Farther removed from the front, and between the two armies
was a morass, the ends of which had been drained, and were
intersected by numerous cuts. And on the more firm ground at the
ends were several small inclosures, with hedges, dry stone walls,
and willow trees.
As the Highlanders were in excellent spirits, and eager to close
immediately with the enemy, Charles felt very desirous to comply
with their wishes; but he soon ascertained, by examining some
people of the neighbourhood, that the passage across the morass,
from the nature of the ground, would be extremely dangerous if not
altogether impracticable. Not wishing, however, in a matter of such
importance to trust altogether to the opinion of the country people,
Lord George Murray ordered Colonel Ker of Gradon, an officer of
some military experience, to examine the ground, and to report.
Mounted upon a little white pony he descended alone into the plain
below, and with the greatest coolness and deliberation surveyed the
morass on all sides. As he went along the morass several shots were
fired at him, by some of Cope’s men, from the sides of the ditches;
but he paid so little regard to these annoyances that, on coming to a
dry stone wall which stood in his way, he dismounted, and making a
gap in it led his horse through. After finishing this perilous duty he
returned to the army, and reported to the lieutenant-general that he
considered it impracticable to pass the morass and attack the enemy
in front, without risking the whole army, and that it was impossible
for the men to pass the ditches in a line.[916]
While his lieutenant-general was, in consequence of this
information, planning a different mode of attack, the prince himself
was moving with a great part of his army towards Dolphinstone on
Cope’s right. Halting opposite Preston tower he seemed to threaten
that flank of the English general, who, thereupon, returned to his
original position with his front to Preston, and his right towards the
sea. As Lord George Murray considered that the only practicable
mode of attacking Cope was by advancing from the east, he led off
part of the army about sunset through the village of Tranent, and
sent notice to the prince to follow him with the remainder as quickly
as possible. When passing through the village Lord George was
joined by fifty of the Camerons, who had been posted by O’Sullivan
in the churchyard at the foot of Tranent. This party being within half
cannon shot of Cope’s artillery, had been exposed during the
afternoon to a fire from their cannon, and one or two of the
Camerons had been wounded. To frighten the Highlanders, who,
they imagined, had never seen cannon before, Cope’s men huzzaed
at every discharge; but the Camerons remained in their position, till,
on the representation of Lochiel, who went and viewed the ground,
and found his men unnecessarily exposed, they were ordered to
retire in the direction of Tranent. O’Sullivan, who was in the rear
when this order was given, came up on the junction of the party,
and asking Lord George the meaning of the movement he was
making, was told by him, that as it was not possible to attack the
enemy with any chance of success on the west side of the village, he
had resolved to assail them from the east, and that he would satisfy
the prince that his plan was quite practicable,—that for this purpose
he had ordered the army to march to the east side of the village,
where there were good dry fields covered with stubble, on which the
men could bivouack during the night,—and that with regard to the
withdrawal of the party which O’Sullivan had posted in the
churchyard, they could be of no service there, and were
unnecessarily exposed. On being informed of the movement made
by Lord George Murray, Charles proceeded to follow him, but it was
dark before the rear had passed the village. To watch Cope’s
motions on the west, Charles left behind the Athole brigade,
consisting of 500 men under Lord Nairne, which he posted near
Preston above Colonel Gardiner’s parks.[917]
After the Highland army had halted on the fields to the east of
Tranent, a council of war was held, at which Lord George Murray
proposed to attack the enemy at break of day. He assured the
members of the council that the plan was not only practicable, but
that it would in all probability be attended with success,—that he
knew the ground himself, and that he had just seen one or two
gentlemen who were also well acquainted with every part of it. He
added, that there was indeed a small defile at the east end of the
ditches, but if once passed there would be no farther hinderance,
and though, from being obliged to march in a column, they would
necessarily consume a considerable time on their march, yet when
the whole line had passed the defile they would have nothing to do
but face to the left, form in a moment, and commence the attack.
Charles was highly pleased with the proposal of the lieutenant-
general; which having received the unanimous approbation of the
council, a few piquets were, by order of Lord George, placed around
the bivouack, and the Highlanders, after having supped, wrapped
themselves up in their plaids, and lay down upon the ground to
repose for the night. Charles, taking a sheaf of pease for a pillow,
stretched himself upon the stubble, surrounded by his principal
officers, all of whom followed his example. Before the army went to
rest, notice was sent to Lord Nairne to leave his post with the Athole
brigade at two o’clock in the morning as quietly as possible. To
conceal their position from the English general, no fires or lights
were allowed, and orders were issued and scrupulously obeyed, that
strict silence should be kept, and that no man should stir from his
place till directed.[918]
When Cope observed Charles returning towards Tranent, he
resumed his former position with his front to the west and his right
to the sea. He now began to perceive that his situation was not so
favourable as he had imagined, and that while the insurgents could
move about at discretion, select their ground, and choose their time
and mode of attack, he was cramped in his own movements, and
could act only on the defensive. The spectators, who felt an interest
in the fate of his army, and who had calculated upon certain success
to Cope’s arms during the day, now, that night was at hand, began
to forebode the most gloomy results. Instead of a bold and decided
movement on the part of Cope to meet the enemy, they observed
that he had spent the day in doing absolutely nothing,—that he was
in fact hemmed in by the Highlanders, and forced at pleasure to
change his position at every movement they were pleased to make.
They dreaded that an army which was obliged to act thus upon the
defensive, and which would, therefore, be obliged to pass the
ensuing night under arms, could not successfully resist an attack
next morning from men, who, sheltered from the cold by their
plaids, could enjoy the sweets of repose and rise fresh and vigorous
for battle.[919]
To secure his army from surprise during the night, Cope placed
advanced piquets of horse and foot along the side of the morass,
extending nearly as far east as the village of Seaton. He, at the
same time, sent his baggage and military chest down to Cockenzie
under a guard of 40 men of the line and all the Highlanders of the
army, consisting of four companies, viz., two of newly raised men
belonging to Loudon’s regiments, and two additional companies of
Lord John Murray’s regiment, which had been diminished by
desertion to fifteen men each.[920] Although the weather had been
very fine, and the days were still warm, yet the nights were now
getting cold and occasionally frosty. As the night in question, that of
Friday the 20th of September, was very cold, Cope ordered fires to
be kindled along the front of his line, to keep his men warm. During
the night he amused himself by firing off, at random, some cohorns,
[921]
probably to alarm the Highlanders or disturb their slumbers, but
these hardy mountaineers, if perchance they awoke for a time,
disregarded these empty bravadoes, and fell back again into the
arms of sleep.
In point of numbers the army of Cope was rather inferior to that
of Charles; but many of the Highlanders were badly armed, and
some of them were without arms. The royal forces amounted
altogether to about 2,300 men; but the number in the field was
diminished to 2,100 by the separation of the baggage-guard which
was sent to Cockenzie. The order of battle formed by Cope along the
north side of the morass was as follows:—He drew up his foot in one
line, in the centre of which were eight companies of Lascelles’s
regiment, and two of Guise’s. On the right were five companies of
Lee’s regiment, and on the left the regiment of Murray, with a
number of recruits for different regiments at home and abroad. Two
squadrons of Gardiner’s dragoons formed the right wing, and a
similar number of Hamilton’s composed the left. The remaining
squadron of each regiment was placed in the rear of its companions
as a reserve. On the left of the army, near the waggon-road from
Tranent to Cockenzie, were placed the artillery, consisting of six or
seven pieces of cannon and four cohorns, under the orders of
Lieutenant-colonel Whiteford, and guarded by a company of Lee’s
regiment, commanded by Captain Cochrane. Besides the regular
troops there were some volunteers, consisting principally of small
parties of the neighbouring tenantry, headed by their respective
landlords. Some Seceders, actuated by religious zeal, had also
placed themselves under the royal standard.[922]
Pursuant to the orders he had received, Lord Nairne left the
position he had occupied during the night at the appointed hour, and
rejoined the main body about three o’clock in the morning. Instead
of continuing the order of march of the preceding night, it had been
determined by the council of war to reverse it. The charge of this
movement was intrusted to Colonel Ker, who had signalized himself
by the calm intrepidity with which he had surveyed the marsh on the
preceding day. To carry this plan into effect, Ker went to the head of
the column, and passing along the line, desired the men to observe
a profound silence, and not to stir a step till he should return to
them. On reaching the rear he ordered it to march from the left, and
to pass close in front of the column, and returning along the line, he
continued to repeat the order till the whole army was in motion. This
evolution was accomplished without the least confusion, and before
four o’clock in the morning the whole army was in full march.[923]
The Duke of Perth, who was to command the right wing, was at
the head of the inverted column. He was attended by Hepburn of
Keith, and Mr. Robert Anderson, son of Anderson of Whitbrough,
who, from his intimate knowledge of the morass, was sent forward
to lead the way. A little in advance of the van was a select party of
60 men doubly armed, under the command of Macdonald of
Glenalladale, major of the regiment of Clanranald, whose appointed
duty it was to seize the enemy’s baggage. The army proceeded in an
easterly direction till near the farm of Ringanhead, when, turning to
the left, they marched in a northerly direction through a small valley
which intersects the farm. During the march the utmost silence was
observed by the men, not even a whisper being heard; and lest the
trampling of horses might discover their advance, the few that were
in the army were left behind. The ford or path across the morass
was so narrow that the column, which marched three men abreast,
had scarcely sufficient standing room, and the ground along it was
so soft that many of the men were almost at every step up to the
knees in mud. The path in question, which was about two hundred
paces to the west of the stone-bridge afterwards built across Seaton
mill-dam, led to a small wooden bridge which had been thrown over
the large ditch that ran through the morass from east to west. This
bridge, and the continuation of the path on the north of it, were a
little to the east of Cope’s left. From ignorance of the existence of
this bridge, from oversight, or from a supposition that the marsh
was not passable in that quarter, Cope had placed no guards in that
direction, and the consequence was, that the Highland army, whose
march across could have been effectually stopped by a handful of
men, passed the bridge and cleared the marsh without interruption.
[924]
The army was divided into two columns or lines, with an interval
between them. After the first line had got out of the marsh, Lord
George Murray sent the Chevalier Johnstone, one of his aides-de-
camp, to hasten the march of the second, which was conducted by
the prince in person, and to see that it passed without noise or
confusion. At the remote end of the marsh there was a deep ditch,
three or four feet broad, over which the men had to leap. In jumping
across this ditch, Charles fell upon his knees on the other side, and
was immediately raised by the Chevalier Johnstone, who says, that
Charles looked as if he considered the accident a bad omen.[925]
Hitherto the darkness had concealed the march of the
Highlanders; but the morning was now about to dawn, and at the
time the order to halt was given, some of Cope’s piquets, stationed
on his left, for the first time heard the tramp of the Highlanders. The
Highlanders then heard distinctly these advanced guards repeatedly
call out, “Who is there?” No answer having been returned, the
piquets immediately gave the alarm, and the cry of “cannons,
cannons; get ready the cannons, cannoneers,” resounded on Cope’s
left wing.[926]
Charles proceeded instantly to give directions for attacking Cope
before he should have time to change his position by opposing his
front to that of the Highland army. It was not in compliance with any
rule in military science, that the order of march of the Highland army
had been reversed; but in accordance with an established punctilio
among the clans, which, for upwards of seven centuries, had
assigned the right wing, regarded as the post of honour, to the
Macdonalds. As arranged at the council of war on the preceding
evening, the army was drawn up in two lines. The first consisted of
the regiments of Clanranald, Keppoch, Glengary, and Glencoe,[927]
under their respective chiefs. These regiments formed the right
wing, which was commanded by the Duke of Perth. The Duke of
Perth’s men and the Macgregors composed the centre; while the left
wing, commanded by Lord George Murray, was formed of the
Camerons under Lochiel, their chief, and the Stewarts of Appin
commanded by Stewart of Ardshiel. The second line, which was to
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like