[PDF Download] Beginning c: from beginner to pro, 7th edition german gonzalez-morris full chapter pd

Page 1


Beginning C: From Beginner to Pro, 7th Edition German Gonzalez-Morris

Visit to download the full and correct content document: https://textbookfull.com/product/beginning-c-from-beginner-to-pro-7th-edition-germangonzalez-morris-2/

More products digital (pdf, epub, mobi) instant download maybe you interests ...

Beginning C: From Beginner to Pro, 7th Edition German Gonzalez-Morris

https://textbookfull.com/product/beginning-c-from-beginner-topro-7th-edition-german-gonzalez-morris-2/

Beginning C: From Beginner to Pro 7th Edition GonzalezMorris

https://textbookfull.com/product/beginning-c-from-beginner-topro-7th-edition-gonzalez-morris/

Beginning Ruby 3: From Beginner to Pro Carleton Dileo

https://textbookfull.com/product/beginning-ruby-3-from-beginnerto-pro-carleton-dileo/

Beginning Unreal Engine 4 Blueprints Visual Scripting: Using C++: From Beginner to Pro Satheesh Pv

https://textbookfull.com/product/beginning-unrealengine-4-blueprints-visual-scripting-using-c-from-beginner-topro-satheesh-pv/

Beginning R 4: From Beginner to Pro 1st Edition Matt Wiley

https://textbookfull.com/product/beginning-r-4-from-beginner-topro-1st-edition-matt-wiley/

Beginning Ruby 3: From Beginner to Pro 4th Edition Carleton Dileo

https://textbookfull.com/product/beginning-ruby-3-from-beginnerto-pro-4th-edition-carleton-dileo/

Beginning R 4: From Beginner to Pro 1st Edition Matt Wiley

https://textbookfull.com/product/beginning-r-4-from-beginner-topro-1st-edition-matt-wiley-2/

Beginning Unreal Engine 4 Blueprints Visual Scripting: Using C++: From Beginner to Pro 1st Edition Satheesh Pv

https://textbookfull.com/product/beginning-unrealengine-4-blueprints-visual-scripting-using-c-from-beginner-topro-1st-edition-satheesh-pv/

Beginning Android Games Development - From Beginner to Pro 4th Edition Ted Hagos

https://textbookfull.com/product/beginning-android-gamesdevelopment-from-beginner-to-pro-4th-edition-ted-hagos/

Beginning C

From Beginner to Pro

7th ed.

German

German Gonzalez-Morris Santiago, Chile

Ivor Horton

STRATFORD UPON AVON, UK

ISBN 979-8-8688-0148-8 e-ISBN 979-8-8688-0149-5

https://doi.org/10.1007/979-8-8688-0149-5

© German Gonzalez-Morris and Ivor Horton 2013, 2020, 2024

This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, speciically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a speciic statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.

The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional afiliations.

This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature. The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.

To my family, Patricia, Raimundo, and Gregorio

—German Gonzalez-Morris

In memory of my beautiful wife, Eve

—Ivor Horton

Introduction

Welcome to Beginning C: From Beginner to Pro, Seventh Edition. With this book, you can become a competent C programmer using the latest version of the C language. In many ways, C is an ideal language with which to learn programming. It’s very compact, so there isn’t a lot of syntax to learn before you can write real applications. In spite of its conciseness, it’s extremely powerful and is used by professionals in many different areas. The power of C is such that it can be applied at all levels, from developing device drivers and operating system components to creating large-scale applications. A relatively new area for C is in application development for mobile phones.

C compilers are available for virtually every kind of computer, so when you’ve learned C, you’ll be equipped to program in just about any context. Once you know C, you have an excellent base from which you can build an understanding of the object-oriented C++.

My objective in this book is to minimize what I think are the three main hurdles the aspiring programmer must face: coming to grips with the jargon that pervades every programming language, understanding how to use the language elements (as opposed to merely knowing what they are), and appreciating how the language is applied in a practical context.

Jargon is an invaluable and virtually indispensable means of communication for the expert professional as well as the competent amateur, so it can’t be avoided. My approach is to ensure that you understand the jargon and get comfortable using it in context. In this way, you’ll be able to more effectively use the documentation that comes along with the typical programming product and also feel comfortable reading and learning from the literature that surrounds most programming languages.

Comprehending the syntax and effects of the language elements is obviously an essential part of learning C, but appreciating how the language features work and how they are used is equally important. Rather than just using code fragments, I provide you with practical working examples in each chapter that show how the language features can be applied to speciic problems. These examples provide a basis for you to experiment and see the effects of changing the code.

Your understanding of programming in context needs to go beyond the mechanics of applying individual language elements. To help you gain this understanding, I conclude most chapters with a more complex program that applies what you’ve learned in the chapter. These programs will help you gain the competence and conidence to develop your own applications and provide you with insight into how you can apply language elements in combination and on a larger scale. Most importantly, they’ll give you an idea of what’s involved in designing real programs and managing real code.

The book’s spirit is to start from a beginner and inish as a pro. Nevertheless, as usual, technology is broad and complex for each part of the knowledge. Therefore, there is always a space to learn more profoundly about each topic. I encourage you to keep learning and researching each aspect you ind more interesting (new knowledge is always good).

It’s important to realize a few things that are true for learning any programming language. First, there is quite a lot to learn, but this means you’ll gain a greater sense of satisfaction when you’ve mastered it. Second, it’s great fun, so you really will enjoy it. Third, you can only learn programming by doing it, and this book helps you along the way. Finally, it’s certain you will make a lot of mistakes and get frustrated from time to time during the learning process. When you think you are completely stuck, you just need to be persistent. You will eventually experience that eureka moment and realize it wasn’t as dificult as you thought.

How to Use This Book

Because I believe in the hands-on approach, you’ll write your irst programs almost immediately. Every chapter has several complete programs that put theory into practice, and these are key to the book. You should type in and run all the examples that appear in the text because the very act of typing them in is a tremendous memory aid. You should also attempt all the exercises that appear at the end of each chapter. When you get a program to work for the irst time— particularly when you’re trying to solve your own problems—you’ll

ind that the great sense of accomplishment and progress makes it all worthwhile.

The pace is gentle at the start, but you’ll gain momentum as you get further into the subject. Each chapter covers quite a lot of ground, so take your time and make sure you understand everything before moving on. Experimenting with the code and trying out your own ideas are important parts of the learning process. Try modifying the programs and see what else you can make them do—that’s when it gets really interesting. And don’t be afraid to try things out—if you don’t understand how something works, just type in a few variations and see what happens. It doesn’t matter if it’s wrong. You’ll ind you often learn a lot from getting it wrong. A good approach is to read each chapter through, get an idea of its scope, and then go back and work through all the examples.

You might ind some of the end-of-chapter programs quite dificult. Don’t worry if it’s not all completely clear on the irst try. There are bound to be bits that you ind hard to understand at irst because they often apply what you’ve learned to rather complicated problems. If you really get stuck, you can skip the end-of-chapter exercises, move on to the next chapter, and come back to them later. You can even go through the entire book without worrying about them. However, if you can complete the exercises, it shows you are making real progress.

Who This Book Is For

Beginning C, Seventh Edition is designed to teach you how to write useful programs in C as quickly and easily as possible. By the end of Beginning C, you’ll have a thorough grounding in programming the C language. This is a tutorial for those of you who’ve done a little bit of programming before, understand the concepts behind it, and want to further your knowledge by learning C. However, no previous programming knowledge on your part is assumed, so if you’re a newcomer to programming, the book will still work for you.

What You Need to Use This Book

To use this book, you’ll need a computer with a C compiler and library installed, so you can execute the examples, and a program text editor for preparing your source code iles. The compiler you use should provide good support for the current international standard for the C language, C23 (ISO/IEC 9899:2023), which is a signiicant update to replace the C17 standard, commonly referred to as C23 or C2x. You’ll also need an editor for creating and modifying your code. You can use any plain text editor such as Notepad++ or vi to create your source program iles. However, you’ll get along better if your editor is designed for editing C code.

I can suggest two sources for a suitable C compiler, both of which are freeware:

The GNU C compiler, GCC, is available from gcc.gnu.org and supports a variety of operating system environments (version 13+).

The Pelles C compiler for Microsoft Windows is downloadable from www.smorgasbordet.com/pellesc/ and includes an excellent integrated development environment (IDE) (version 12+).

Conventions Used

I use a number of different styles of text and layout in the book to help differentiate between the different kinds of information. For the most part, their meanings will be obvious. Program code will appear like this:

int main(void)

{

printf("Beginning C\n"); return 0; }

When a code fragment is a modiied version of a previous instance, I occasionally show the lines that have changed in bold type like this:

int main(void)

{

printf("Beginning C by Ivor Horton & German Gonzalez-Morris\n"); return 0; }

When code appears in the text, it has a different typestyle that looks like this: double.

I’ll use different types of “brackets” in the program code. They aren’t interchangeable, and their differences are very important. I’ll refer to the symbols ( ) as parentheses, the symbols { } as braces, and the symbols [ ] as square brackets.

Important new words in the text are shown in italic like this. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/9781484259757. For more detailed information, please visit www.apress.com/sourcecode.

Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub. For more detailed information, please visit https://www.apress.com/gp/services/source-code.

Acknowledgments

I am profoundly grateful to Patricia Cruces, my life partner, whose ininite patience, unwavering support, and boundless love have been my constant companions through every challenge and triumph. Her presence has been a source of inspiration, making this journey more meaningful and fulilling.

To my sons, Raimundo and Gregorio, I owe immeasurable thanks for being the bright sparks of joy and inspiration in my life. Your happiness reminds me of what truly matters, and your enthusiasm ills me with determination.

To my parents, German and Felicia Morris, who have been my pillars of strength, providing both love and guidance and invaluable educational opportunities.

To my friend Daniel Lagos, a great engineer, whose constructive criticism, suggestions, exchange of ideas, and feedback have not only helped my understanding with his input but have inspired me to explore alternative approaches and support continuous improvement. I appreciate the collaborative spirit demonstrated by my university classmates Alejandro Cuevas and Fernando Castillo, as their diverse perspectives have contributed to more comprehensive, real-world examples and practical applications, particularly to my lessons on C language pointers.

I am grateful for the support and opportunities provided to me by the entire Apress team, especially Melissa Duffy and Sowmya Thodur. Their guidance and advice have been invaluable. I also want to thank Megan Hirni, the technical reviewer, for her clever feedback, suggestions, and corrections.

—German Gonzalez-Morris

Table of Contents

Chapter 1: Programming in C

The C Language

The Standard Library

Learning C

Creating C Programs

Editing

Compiling

Linking

Executing

Creating Your First Program

Editing Your First Program

Dealing with Errors

Dissecting a Simple Program

Comments

Preprocessing Directives

Deining the main() Function

Keywords

The Body of a Function

Outputting Information

Function Arguments

Control Characters

Trigraph Sequences

The Preprocessor

Developing Programs in C

Understanding the Problem

Detailed Design

Implementation

Testing

Functions and Modular Programming

Common Mistakes

Points to Remember

Summary

Chapter 2: First Steps in Programming

Memory in Your Computer

What Is a Variable?

Naming Variables

Variables That Store Integers

Using Variables

Initializing Variables

More on Division with Integers

Unary Operators

Unary Minus Operator

Variables and Memory

Signed Integer Types

Unsigned Integer Types

Specifying Integer Constants

Binary Integer Constants

Working with Floating-Point Numbers

Floating-Point Number Representation

Floating-Point Variables

Division Using Floating-Point Values

Controlling the Number of Decimal Places in the Output

Controlling the Output Field Width

More Complicated Expressions

Checked Integer Arithmetic

constexpr

Deining Named Constants

Knowing Your Limitations

Introducing the sizeof Operator

Choosing the Correct Type for the Job

Explicit Type Conversion

Automatic Conversions

Rules for Implicit Conversions

Implicit Conversions in Assignment Statements

Type Inference

typeof

More Numeric Data Types

Character Type

Character Input and Character Output

Enumerations

Choosing Enumerator Values

Unnamed Enumeration Types

Variables That Store Boolean Values

The op= Form of Assignment

Mathematical Functions

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 3: Making Decisions

The Decision-Making Process

Arithmetic Comparisons

The Basic if Statement

Extending the if Statement: if-else

Using Blocks of Code in if Statements

Nested if Statements

Testing Characters

Logical Operators

The Conditional Operator

Operator Precedence: Who Goes First?

Multiple-Choice Questions

Using else-if Statements for Multiple Choices

The switch Statement

The goto Statement

Bitwise Operators

The op= Use of Bitwise Operators

Using Bitwise Operators

Bit-Precise Integers

Modern Bit Utilities

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 4: Loops

How Loops Work

Introducing the Increment and Decrement Operators

The for Loop

General Form of the for Loop

More on the Increment and Decrement Operators

The Increment Operator

The Preix and Postix Forms of the Increment Operator

The Decrement Operator

The for Loop Revisited

Modifying the for Loop Control Variable

A for Loop with No Parameters

The break Statement in a Loop

Limiting Input Using a for Loop

Generating Pseudo-random Integers

More for Loop Control Options

Floating-Point Loop Control Variables

Chars loop Control Variables

The while Loop

Nested Loops

Nested Loops and the goto Statement

The do-while Loop

The continue Statement

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 5: Arrays

An Introduction to Arrays

Programming Without Arrays

What Is an Array?

Using an Array

The Address of Operator

Arrays and Addresses

Initializing an Array

Compound Literal

Finding the Size of an Array

Multidimensional Arrays

Initializing Multidimensional Arrays

Constant Arrays

Variable-Length Arrays

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 6: Applications with Strings and Text

What Is a String?

Variables That Store Strings

Arrays of Strings

Operations with Strings

Checking for C11/C23 Support

Finding the Length of a String

Copying Strings

Concatenating Strings

Comparing Strings

Searching a String

Tokenizing a String

Reading Newline Characters into a String

Analyzing and Transforming Strings

Converting Character Case

Converting Strings to Numerical Values

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 7: Pointers

A First Look at Pointers

Declaring Pointers

Accessing a Value Through a Pointer

Using Pointers

Testing for a NULL Pointer

Pointers to Constants

Constant Pointers

Naming Pointers

Arrays and Pointers

Multidimensional Arrays

Multidimensional Arrays and Pointers

Accessing Array Elements

Using Memory As You Go

Dynamic Memory Allocation: The malloc() Function

Releasing Dynamically Allocated Memory

Memory Allocation with the calloc() Function

Extending Dynamically Allocated Memory

Handling Strings Using Pointers

Using Arrays of Pointers

Pointers and Array Notation

Designing a Program

The Problem

The Analysis

The Solution

The Complete Program

Summary

Chapter 8: Structuring Your Programs

Program Structure

Variable Scope and Lifetime

Variable Scope and Functions

Storage classes

Functions

Deining a Function

The return Statement

The Pass-by-Value Mechanism

Function Prototypes

Pointers As Parameters and Return Types

const Parameters

Perils of Returning Pointers

Summary

Chapter 9: More on Functions

Pointers to Functions

Declaring a Pointer to a Function

Calling a Function Through a Function Pointer

Arrays of Pointers to Functions

Pointers to Functions As Arguments

Variables in Functions

Static Variables: Keeping Track Within a Function

Sharing Variables Between Functions

Functions That Call Themselves: Recursion

Functions with a Variable Number of Arguments

Copying a va_list

Basic Rules for Variable-Length Argument Lists

The main( ) Function

Terminating a Program

The abort() Function

The exit() and atexit() Functions

The _Exit() Function

The quick_exit() and at_quick_exit() Functions

Enhancing Performance

Declaring Functions Inline

Using the restrict Keyword

The _ Noreturn Function Speciier

Attributes

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 10: Essential Input and Output

Input and Output Streams

Standard Streams

Input from the Keyboard

Formatted Keyboard Input

Input Format Control Strings

Characters in the Input Format String

Variations on Floating-Point Input

Reading Hexadecimal and Octal Values

Reading Characters Using scanf_s()

String Input from the Keyboard

Single-Character Keyboard Input

Output to the Screen

Formatted Output Using printf_s()

Escape Sequences

Integer Output

Outputting Floating-Point Values

Character Output

Other Output Functions

Unformatted Output to the Screen

Formatted Output to an Array

Formatted Input from an Array

Summary

Chapter 11: Structuring Data

Data Structures: Using struct

Deining Structure Types and Structure Variables

Accessing Structure Members

Unnamed Structures

Arrays of Structures

Structure Members in Expressions

Pointers to Structures

Dynamic Memory Allocation for Structures

More on Structure Members

Structures As Members of a Structure

Declaring a Structure Within a Structure

Pointers to Structures As Structure Members

Doubly Linked Lists

Bit Fields in a Structure

Structures and Functions

Structures As Arguments to Functions

Pointers to Structures As Function Arguments

Structure As a Function Return Value

Binary Trees

Sharing Memory

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 12: Working with Files

The Concept of a File

Positions in a File

File Streams

Accessing Files

Opening a File

Buffering File Operations

Renaming a File

Closing a File

Deleting a File

Writing a Text File

Reading a Text File

Reading and Writing Strings to a Text File

Formatted File Input and Output

Formatted Output to a File

Formatted Input from a File

Dealing with Errors

More Open Modes for Text Files

The freopen_s( ) Function

Binary File Input and Output

Opening a File in Binary Mode

Writing a Binary File

Reading a Binary File

Moving Around in a File

File Positioning Operations

Finding Out Where You Are

Setting a Position in a File

Using Temporary Work Files

Creating a Temporary Work File

Creating a Unique File Name

Updating Binary Files

Changing the Contents of a File

Creating a Record from Keyboard Input

Writing a Record to a File

Reading a Record from a File

Writing a File

Listing the File Contents

Updating the Existing File Contents

File Open Mode Summary

Designing a Program

The Problem

The Analysis

The Solution

Summary

Chapter 13: The Preprocessor and Debugging

Preprocessing

Including Header Files

Deining Your Own Header Files

Managing Multiple Source Files

External Variables

Static Functions

Substitutions in Your Program Source Code

Macros

Macros That Look Like Functions

Strings As Macro Arguments

Joining Two Arguments in a Macro Expansion

Preprocessor Directives on Multiple Lines

Logical Preprocessor Directives

Conditional Compilation

Testing for Multiple Conditions

Undeining Identiiers

Testing for Speciic Values for Identiiers

Multiple-Choice Selections

Standard Preprocessing Macros

_ Generic Macro

The Unreachable Macro

Debugging Methods

Integrated Debuggers

The Preprocessor in Debugging Assertions

Date and Time Functions

Getting Time Values

Getting the Date

Getting the Day for a Date

Summary

Chapter 14: Advanced and Specialized Topics

Working with International Character Sets

Understanding Unicode

Setting the Locale

The Wide Character Type wchar_t

Operations on Wide Character Strings

File Stream Operations with Wide Characters

Fixed Size Types That Store Unicode Characters

Specialized Integer Types for Portability

Fixed-Width Integer Types

Minimum-Width Integer Types

Maximum-Width Integer Types

The Complex Number Types

Complex Number Basics

Complex Types and Operations

Programming with Threads

Creating a Thread

Exiting a Thread

Joining One Thread to Another

Suspending a Thread

Managing Thread Access to Data

Summary

Appendix A: Computer Arithmetic

Appendix B: ASCII Character Code Deinitions

Appendix C: Reserved Words in C

Appendix D: Input and Output Format Speciications

Appendix E: Standard Library Header Files

Index

About the Authors

German Gonzalez-Morris is a polyglot software architect/engineer with 20+ years in the ield, with knowledge in Java, SpringBoot, C/C++, Julia, Python, Haskell, and JavaScript, among others. He works for cloud (architecture), web-distributed applications, and microservices. German loves math puzzles (including reading Knuth, proud of solving some of Don’s puzzles), swimming, and table tennis. Also, he has reviewed several books, including those on application containers (WebLogic) and languages (C, Java, Spring, Python, Haskell, TypeScript, WebAssembly, Math for coders, regexp, Julia, data structures, and algorithms). You can see details on his blog (https://devwebcl.blogspot.com/) or X/Twitter account (@devwebcl)

Ivor Horton is self-employed in consultancy and writes programming tutorials. He worked for IBM for many years and holds a bachelor’s degree, with honors, in mathematics. Ivor’s experience at IBM includes programming in most languages (such as assembler and high-level languages on a variety of machines), real-time programming, and designing and implementing real-time closed-loop industrial control systems. He has extensive experience teaching programming to engineers and scientists (Fortran, PL/1, APL, etc.). Ivor is an expert in mechanical, process, and electronic CAD systems; mechanical CAM systems; and DNC/CNC systems.

Another random document with no related content on Scribd:

VALUABLE WORK.

There can scarcely be anyone who will question the educational value of such visits as these. Not only are they of great value educationally to those privileged to take part in them, but the results of the investigations carried out, when made available as these were, in book or pamphlet form, convey much valuable information and become the means of imparting many new ideas to people to whom the larger books in which such information is to be found are not available. If they should have served, in however small a measure, in penetrating the veneer of complacency with which the average untravelled and uninformed Co-operator regards his own movement as in all things the last word in perfection of organisation and treatment of those employed, they would be worth far more to the movement than the few pounds which each trip cost.

THE YEARS OF WAR.

At first the war did not make much difference to the work of the educational committee or of its agencies, but as more and more of the younger male employees were called up or joined voluntarily, there was a perceptible falling off in the membership of the various agencies. The rowing club had to suspend operations altogether, and the band was hard put to it to maintain the balance of instruments, new players having to be brought in to take the places of those who had joined up. Meantime a senior choir had been formed, and did much good work, not only by providing concerts in St Mungo Hall, but by singing at concerts organised in aid of war charities and to provide entertainment for convalescent soldiers. In work of a semimilitary character, the band also took a full share.

The educational committee also took charge of the funds organised by the various departments to provide parcels for employees serving with the Forces, and in this way a constant stream of parcels went from the Bakery to distant comrades. The provision of lectures by prominent men and women in the Co-operative and kindred movements continued to be a feature of the work carried on by the committee each winter, while it was usually arranged that some prominent Co-operator should give an address at the quarterly meeting held under the auspices of the committee, such addresses being generally on matters of current interest.

The work of an educational committee is usually arduous and somewhat discouraging. In commercial work the results of a policy are generally forthcoming immediately, but educational work is somewhat like scattering bread upon the waters. Doubtless good results accrue, but time must elapse before they show themselves, and the intervening period is one of faith and hope. Then, also, educational work is work in which a departure from stereotyped methods is necessary occasionally. There is a monotony in doing the same work year after year, which tends to “grooviness,” and this is a danger which must be avoided at all hazards, for from “grooviness” comes staleness and with staleness comes satiety. When an

educational committee breaks new ground, as the Baking Society’s committee did in 1913 with their deputation to works of prominent firms in England, interest is stimulated, and even the stereotyped work takes on a new freshness. In the future we may hope to see the good work already done by the Baking Society’s educational committee broadening out in new directions, and acquiring fresh vigour with new successes. The educational committee has been in the past a welfare committee in the best meaning of that word, and without any of the prying, sometimes nicknamed “spying” by the employees, it has done much to promote the physical and mental wellbeing of those for whom it works. As the years pass, fresh outlets in this direction for its energies will also manifest themselves, and these it will take advantage of as readily as it has done in the past.

CHAPTER XXI. MEN WHO WROUGHT.

GABRIEL THOMSON—JAMES BORROWMAN—DAVID SMITH

—ROBERT CRAIG—WILLIAM BARCLAY—THOMAS SLATER

—ANDREW BROWN—ALEXANDER FRASER—JOHN FERGUSON—DUNCAN M‘CULLOCH—JAMES H. FORSYTH

—JAMES YOUNG—PETER GLASSE—DANIEL H. GERRARD —JAMBS BAIN—THE BOARD AT THE END OF FIFTY YEARS.

The Co-operative movement has ever been rich in men and women who have given to it devoted, whole-hearted, and able service. There have always been men with sufficient faith in the principles on which the movement is based to spend themselves, their energies and their money, in furthering it, from the days when Robert Owen, working to better the conditions of the miserable creatures who were helping to pile up wealth for himself and his partners, discovered that it was through striving to help others that man could best help himself, and devoted his wealth and the remainder of his life to the promulgation of this doctrine. In men whose faith in this principle was great and whose work for its enthronement in the councils of the world was arduous the United Co-operative Baking Society has been rich. They have all of them been men who believed that Co-operation was the true principle of progress, and in their own way and time each one did his best to further the cause he had at heart.

GABRIEL THOMSON.

It is peculiar that of the man who played perhaps the most prominent part in the work of establishing the United Baking Society little has been placed on record. Mr Gabriel Thomson was a man in late middle life when the proposal to establish the S.C.W.S. was being discussed. He was a representative of St Rollox Society at the meeting at which it was finally decided that a Scottish Wholesale Society should be established, and moved the resolution to that effect. When the committee was being formed he was appointed treasurer, and when the proposal for a federated bread baking society was being discussed he read a paper on the subject which went far to decide the delegates in favour of the proposal to establish the United Baking Society, there also moving the resolution in favour of its formation. He was appointed first chairman of the Society, thus acting as chairman of the U.C.B.S. and treasurer of the S.C.W.S. at the one time; but he only remained at the head of affairs for the first year, and his official connection with the Society then severed. He died in the Townhead district about the end of the century.

JAMES BORROWMAN.

Those who knew James Borrowman have described him as one of the most effective Co-operative propagandists and platform men that the movement in Scotland has produced. He was a man of boundless energy and enthusiasm, and was filled with a lofty idealism which caused him to look ever ahead beyond the petty difficulties of the moment. Unfortunately, his abounding faith in the possibilities of Co-operation caused him to overlook sometimes the immediate and practical difficulties in the way and, reversing the position of the men who are unable to see the wood for the trees, his gaze was fixed so firmly on the beautiful vista ahead that he failed to observe the rocks in the pathway on which he trod until he had stumbled over them. Mr Borrowman was one of the pioneers of Crosshouse Society, but at the time when the Baking Society was being discussed he had just been appointed manager of the newly formed Wholesale Society and had joined the Anderston Society. He worked faithfully as secretary of the Baking Society until pressure of work for the S.C.W.S. caused him to resign, and but a few years later his unquenchable optimism caused him to make the mistake of allowing the Ironworks Society to overdraw largely on the Wholesale Society. This finished his outstanding work for the cause of Co-operation.

DAVID SMITH.

When Mr Borrowman resigned the secretaryship of the Baking Society he was succeeded by Mr David Smith, who had been acting as assistant secretary for some months before the resignation took place. Mr Smith was a representative of St Rollox Society on the board of the U.C.B.S., making his first appearance as a representative from that society at the committee meeting which was held on 15th March 1872. On the resignation, in the summer of 1875, of Mr Robert Craig from the management of the Society, Mr Smith was appointed manager, and continued to act in that capacity until the end of 1889, when he resigned in order to start in business as a baker in Maryhill. Unfortunately, he did not succeed, and shortly afterwards went to South Africa. Evidently he did not find things to his liking there, for in a year or two he was back in Scotland again, and was acting as master of works in connection with the reconstruction work of the Drapery and Furnishing Society. He died almost exactly seven years after severing his connection with the Baking Society.

ROBERT CRAIG.

Mr Robert Craig was only a short time—two and a half years—in the service of the Society, but during that short period he did such good work as to cause a general regret on the part of those who knew him when ill-health caused him to sever his connection with it. In a vain effort to restore his health he went to Spain, but, finding that he was not benefiting by the change, he returned to Glasgow again, where he died in 1877. Mr Craig was a native of Barrhead, and before taking up his duties as cashier to the Baking Society he acted as bookkeeper with the Wholesale Society. He seems to have been of a most lovable disposition, beloved by all who came into contact with him.

WILLIAM BARCLAY.

The name of William Barclay will always be associated with the Scottish Co-operative Convalescent Homes Association, which he helped to found, and for which he worked earnestly and enthusiastically. In the early days of the U.C.B.S. he was associated with St Rollox Society, and it was as a member of that society that he was appointed to the chair of the Baking Society in 1870. He continued to act as chairman for fifteen months only, and then severed his connection with the committee. In his later years he was associated with Kinning Park Society, and it was as a member of that society that he did his work in connection with the Homes Association.

THOMAS SLATER.

When Mr David Smith resigned the secretaryship of the Society to take up its management he was succeeded by Mr Thomas Slater, who represented London Road Society on the board, and Mr Slater continued to act as secretary until the end of 1887. During his term of office Mr Slater had proven himself a most efficient and painstaking secretary, and it was due to his initiative that the ground annual of the St James Street property was purchased by the Society. After ceasing his official connection with the Society he continued to take a keen interest in its affairs and at times even to criticise the policy of the directors through the columns of the press.

ANDREW BROWN.

It is probable that it was to the wise guidance of Mr Andrew Brown more than to the work of any other man that the Baking Society was able to overcome the difficulties of its early days. He was appointed to the chair in 1872, and continued to act as president during all the strenuous days when the proposals for building a branch bakery farther west were being discussed with vigour. When he became president the Society had many difficulties to contend with, not the least of which were inefficient workmen, while shortage of money retarded its operations to a very great extent. Mr Brown continued to act as chairman until his society—Paisley Provident—withdrew from membership at the end of 1880. All those who had the pleasure of knowing him speak of him as a cautious leader, shrewd and clearsighted, who always took a business view of the proposals which came before the committee. Thus he was able to steer clear of the many pitfalls which lined the pathway of his Society.

ALEXANDER FRASER.

Mr Alexander Fraser succeeded Mr Brown in the chair. At the time of his appointment to the chair he had been continuously a member of the board of the Society from March 1873, as the representative of Busby Society, and he continued to perform the duties of president of the Society until the quarterly meeting which was held in December 1887. Mr Fraser had thus an unbroken connection with the committee of the Society for the long period of fourteen years, until then the longest period during which any member had filled a seat on the board. During his term of office he had seen the Society grow wondrously. He had seen it become too big for its home at St James Street, and had steered it safely to its new home, erected specially for its occupation, at M‘Neil Street, and he felt that, that task accomplished, he did well to lay aside his task. He was a worthy successor to Mr Brown and a worthy predecessor of the men who followed him.

JOHN FERGUSON.

Mr Fraser was succeeded by Mr John Ferguson, of Glasgow Eastern Society. Before Mr Ferguson came to the Baking Society’s board he had filled many positions of responsibility in the Eastern Society. He was member of the committee for a number of years, a member of the first educational committee of the society when it was formed in 1876, and was also president of the society for a number of years. In his own society and in the Baking Society he did good work for Co-operation, and was much respected by all who came into contact with him. He, too, joined the great majority a number of years ago.

DUNCAN M‘CULLOCH.

Mr Duncan M‘Culloch was born in the little village of Carfin in Lanarkshire. After serving his apprenticeship as a joiner in Wishaw, he came to Glasgow, and on marrying became connected with Kinning Park Society. In 1887 he was made president of the society, and afterwards a member of the then newly formed educational committee. He took a prominent part in the formation of the first branch of the Scottish Co-operative Women’s Guild—Kinning Park Central branch—and came to be known amongst the ladies of the guild as “The Father of the Guild,” a title of which he was justly proud. After having been for a short time a member of the committee of the Baking Society, he was elected chairman in 1889, and continued to occupy that honourable position for the long period of fifteen years. During these years the Baking Society entered on a period of expansion which raised it from the position of a moderately sized bakery, doing a trade of 700 sacks a week, to that of the largest institution of its kind, with a trade of almost 4,000 sacks weekly. He saw the biscuit factory started, and during his term of office the Clydebank branch was opened and the Belfast branch was commenced. Mr M‘Culloch also took a warm interest in the affairs of the Convalescent Homes Association, and he served for many years, until his death in the summer of 1915, as a director of this, “the brightest jewel in the Co-operative crown,” as the chairman of the Homes Association sometimes describes it. Mr M‘Culloch became again a president of Kinning Park Society, and there, as in the work of the Baking Society, he displayed enterprise, acumen, and firmness. He was a man of strong will and dominant personality, and his work on the various boards of the Co-operative movement with which he was associated was always marked by strong common sense. On the Co-operative Defence Committee and on the Scottish Sectional Board he was also a tower of strength; never favouring schemes or policies which were far in advance of the times, but never holding back when he thought action was for the benefit of the movement to which he had devoted the leisure moments of his life. For some time in 1915 he had been laid aside with illness, and as the

Congress of that year met for its first session the news of his death arrived and cast a gloom over the minds of the Scotsmen present, who felt that one who had been all a man had gone from them.

JAMES H. FORSYTH.

The genial cashier of the Baking Society is one of the best known and most highly respected business men in the Co-operative movement. His balance-sheets are models of lucidity, and this feature is often commented on in the columns of the financial press. Mr Forsyth has had a lifelong acquaintance with Co-operative accounting. As a lad he entered the office of the Wholesale Society, and waited there until, as he himself has put it, he began to understand what double entry bookkeeping really was. Then a desire to see other lands possessed him for a time, and he voyaged to the great Republic of the West. He had been there for only two years, however, when the homing instinct possessed him, and returning to Glasgow, after a short interval, entered the office of the Baking Society as bookkeeper. Here he had been for some four years when Mr David Smith retired from the management of the Society, and the board, deciding that they were going to try and work the Society for a time at least without a manager, appointed Mr Forsyth cashier and bookkeeper, and cashier and bookkeeper he has been ever since. Mr Forsyth is one of those officials who treat the business for which they work as if it was their own. He is indefatigable in his efforts to maintain and even to improve the wellbeing and to accelerate the progress of the Baking Society, and during the strenuous years of the war, when the demands of the War Office were depleting his staff, nevertheless he “carried on” in a manner which won the approval of management and delegates alike. He is one of those careful, painstaking officials who are assets of great value to the societies fortunate enough to possess them.

JAMES YOUNG.

Mr James Young, the widely respected manager of the Baking Society, is an idealist turned business man. He has the vision of the poet, and is ever looking forward from the sordid to-day to the brighter and better to-morrow; but he is none the less a business man. He served on the board of the Baking Society as a representative of Uddingston Society for some three years before he was appointed, in 1899, manager of the Society. Since then he has conducted the business of the Society wisely and well, and his advice is eagerly sought after in matters connected with the trade. He is very popular with all with whom business brings him into contact, for he is recognised by all to be a man of high principle, who is incapable of stooping to anything mean. To this aspect of his character is probably due the remarkably good terms which have always existed between the Society and the employees, for he is kind and considerate to those whom fortune has placed under his charge. Unfortunately, in these latter years his health has not been quite as robust as his friends would like, but one and all hope that many years of service yet remain to him.

PETER GLASSE.

Mr Peter Glasse succeeded Mr Slater as secretary. He was the representative of St George on the board of the Baking Society at the time of Mr Slater’s resignation, and was for many years one of the most active Co-operators in the West of Scotland. He took a very active part in all the strenuous work which fell to the lot of good platform men during and after the boycott of 1896–97. On several occasions he served with distinction in the chair of his own society, and was for many years a member of the board of the Wholesale Society. He demitted office as secretary of the Baking Society in the spring of 1895. From 1896 until the merging of the West of Scotland Co-operative Defence Committee in the National Co-operative Defence Association, Mr Glasse acted as chairman of the committee, and then as chairman of the National Association until its work was merged in that of the Scottish Sectional Board. He died early in 1917 after a life which had been full of service to Co-operation.

D. H. GERRARD, J.P.

Mr Daniel H. Gerrard, J.P., is one of the best known figures in the Co-operative movement, and it is a matter for sincere regret to his many friends that he is not able to go out and in amongst them as of yore, and doubly regrettable that illness should have stricken him down two months before the Society for which he had worked so hard completed its fiftieth year of existence. Mr Gerrard is a Southerner, but he has lived so long in Scotland that he has become acclimatised. His first connection with Co-operation was with the second Maryhill Society, in the formation of which he took an active part, and of which he was president for many years. When that society amalgamated with St George he threw himself with equal vigour and success into the work of his new society, and ere long was appointed to the presidency. Then fifteen years ago he was elected to the chair of the Baking Society, and continued to act in that capacity until he was compelled by the orders of his medical man to give it up. He was an able and earnest advocate of Co-operation, and took an active part in the strenuous work of the boycott days as well as in Cooperative missionary work in Ireland and elsewhere. It is the earnest wish of all friends that in his retirement he will be long spared to look back with complacency over his many fights for the cause he loved.

JAMES BAIN.

Mr James Bain, the genial secretary of the Baking Society, has had a long and active connection with the cause of Co-operation in Glasgow. He succeeded Mr John Ferguson as chairman of Glasgow Eastern Society, and was chairman of that society when the Dalmarnock Road premises were opened in 1893. He was also treasurer of the society for a number of years. In the spring of 1895 he was elected secretary of the Baking Society in succession to Mr Glasse, and that position he continues to fill with honour to himself and profit to the Society. Nor, although the secretaryship of the Baking Society would seem to be enough spare-time work for any man, does he rest content with that. Ever since its formation he has acted as president of that beneficent Co-operative institution, the Cooperative Veterans Association. In his work for the Bakery he has always been conscientious and clear, and has also done much work which lies outside his special work as secretary. For example, he read a paper a number of years ago at a conference of representatives of the Glasgow societies, in which he advocated strongly the desirability of establishing a system of bread baking which would enable the bakers to begin their work at a reasonable hour. He is getting on in years now, but his minutes are as clearly written as ever, and his many friends hope that it will be long ere he has to lay down his secretarial pen.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.