100% found this document useful (4 votes)
28 views

(Ebook) Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language by Dmitrović, Slobodan ISBN 9781484266434, 1484266439 all chapter instant download

The document provides information about the ebook 'Modern C for Absolute Beginners' by Slobodan Dmitrović, including multiple ISBNs and links for download. It outlines the contents of the book, which covers fundamental concepts of the C programming language, along with exercises and modern C standards. Additionally, it mentions supplementary materials available on GitHub and acknowledges contributions from various individuals in the writing process.

Uploaded by

abreoryderyk
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
100% found this document useful (4 votes)
28 views

(Ebook) Modern C for Absolute Beginners: A Friendly Introduction to the C Programming Language by Dmitrović, Slobodan ISBN 9781484266434, 1484266439 all chapter instant download

The document provides information about the ebook 'Modern C for Absolute Beginners' by Slobodan Dmitrović, including multiple ISBNs and links for download. It outlines the contents of the book, which covers fundamental concepts of the C programming language, along with exercises and modern C standards. Additionally, it mentions supplementary materials available on GitHub and acknowledges contributions from various individuals in the writing process.

Uploaded by

abreoryderyk
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/ 65

Download the Full Ebook and Access More Features - ebooknice.

com

(Ebook) Modern C for Absolute Beginners: A


Friendly Introduction to the C Programming
Language by Dmitrovi , Slobodan ISBN
9781484266434, 1484266439
https://ebooknice.com/product/modern-c-for-absolute-
beginners-a-friendly-introduction-to-the-c-programming-
language-23942580

OR CLICK HERE

DOWLOAD EBOOK

Download more ebook instantly today at https://ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) Modern C for Absolute Beginners by Slobodan Dmitrovi [Dmitrovi■, Slobodan]


ISBN 9781484266427, 9781484266434, 1484266420, 1484266439

https://ebooknice.com/product/modern-c-for-absolute-beginners-36253462

ebooknice.com

(Ebook) Modern C for Absolute Beginners: A Friendly Introduction to the C


Programming Language by Slobodan Dmitrovi■ ISBN 9781484266427, 1484266420

https://ebooknice.com/product/modern-c-for-absolute-beginners-a-friendly-
introduction-to-the-c-programming-language-23942578

ebooknice.com

(Ebook) Modern C for Absolute Beginners: A Friendly Introduction to the C


Programming Language by Slobodan Dmitrovi■ ISBN 9798868802232, 8868802236

https://ebooknice.com/product/modern-c-for-absolute-beginners-a-friendly-
introduction-to-the-c-programming-language-56083684

ebooknice.com

(Ebook) Modern C++ for Absolute Beginners: A Friendly Introduction to C++


Programming Language and C++11 to C++20 Standards by Slobodan Dmitrovi■ ISBN
9781484260463, 1484260465

https://ebooknice.com/product/modern-c-for-absolute-beginners-a-friendly-
introduction-to-c-programming-language-and-c-11-to-c-20-standards-11279556

ebooknice.com
(Ebook) Modern C++ for Absolute Beginners: A Friendly Introduction to the C++
Programming Language and C++11 to C++23 Standards, 2nd Edition by Slobodan Dmitrovi■
ISBN 9781484292730, 1484292731

https://ebooknice.com/product/modern-c-for-absolute-beginners-a-friendly-
introduction-to-the-c-programming-language-and-c-11-to-c-23-standards-2nd-
edition-48278302

ebooknice.com

(Ebook) Modern C++ for Absolute Beginners: A Friendly Introduction to C++


Programming Language and C++11 to C++20 Standards by Slobodan Dmitrovi■ ISBN
9781484260470, 1484260473, b6f80b55-cf7e-44ca-902e-e3927f78fbfc,
B6F80B55-CF7E-44CA-902E-E3927F78FBFC
https://ebooknice.com/product/modern-c-for-absolute-beginners-a-friendly-
introduction-to-c-programming-language-and-c-11-to-c-20-standards-44441424

ebooknice.com

(Ebook) Modern C++ for Absolute Beginners by Slobodan Dmitrovi■ [Dmitrovi■,


Slobodan] ISBN 9781484260470, 1484260473

https://ebooknice.com/product/modern-c-for-absolute-beginners-22736378

ebooknice.com

(Ebook) Modern C for Absolute Beginners by Slobodan Dmitrovic ISBN 9781484266427,


1484266420

https://ebooknice.com/product/modern-c-for-absolute-beginners-23198666

ebooknice.com

(Ebook) Modern C for Absolute Beginners. A Friendly Introduction by Dmitrovic,


Solbodan ISBN 9798868802232, 9798868802249, 8868802236, 8868802244

https://ebooknice.com/product/modern-c-for-absolute-beginners-a-friendly-
introduction-56093266

ebooknice.com
Slobodan Dmitrović

Modern C for Absolute Beginners


A Friendly Introduction to the C Programming
Language
1st ed.
Slobodan Dmitrović
Belgrade, Serbia

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/​9781484266427. For more
detailed information, please visit http://​www.​apress.​com/​source-code.

ISBN 978-1-4842-6642-7 e-ISBN 978-1-4842-6643-4


https://doi.org/10.1007/978-1-4842-6643-4

© Slobodan Dmitrović 2021

This work is subject to copyright. All rights are reserved by the


Publisher, whether the whole or part of the material is concerned,
specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms 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 specific 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 affiliations.

Distributed to the book trade worldwide by Apress Media, LLC, 1 New


York Plaza, New York, NY 10004, U.S.A. Phone 1-800-SPRINGER, fax
(201) 348-4505, e-mail [email protected], or visit
www.springeronline.com. Apress Media, LLC is a California LLC and the
sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For Sanja and Katarina
Acknowledgments
I would like to thank my friends and fellow peers who have supported
me in writing my second book.
I am forever indebted to Peter Dunne, Glenn Dufke, Bruce McGee,
Tim Crouse, Jens Fudge, Rainer Grimm, and Rob Machin for all their
work, help, and support.
I am grateful to the outstanding professionals at Apress who have
supported me during the entire writing process.
I am thankful to all of the amazing software developers, architects,
and entrepreneurs I met and collaborated with throughout the years.
Table of Contents
Part I: The C Programming Language
Chapter 1:​Introduction
1.​1 What Is C?​
1.​2 What Is C Used For?​
1.​3 C Compilers
1.​3.​1 Installing Compilers
1.​4 C Standards
Chapter 2:​Our First Program
2.​1 Function main()
2.​2 Comments
2.​3 Hello World
Chapter 3:​Types and Declarations
3.​1 Declarations
3.​2 Introduction
3.​3 Character Type
3.​4 Integer Type
3.​5 Floating-Point Types
3.​5.​1 float
3.​5.​2 double
3.​5.​3 long double
Chapter 4:​Exercises
4.​1 Hello World with Comments
4.​1.​1 Declaration
4.​1.​2 Definition
4.​1.​3 Outputting Values
Chapter 5:​Operators
5.​1 Introduction
5.​2 Arithmetic Operators
5.​3 Assignment Operator
5.​4 Compound Assignment Operators
5.​5 Relational Operators
5.​6 Equality Operators
5.​7 Logical Operators
5.​8 Increment and Decrement Operators
5.​9 Operator Precedence
Chapter 6:​Expressions
6.​1 Initialization
6.​2 Type Conversion
Chapter 7:​Statements
7.​1 Introduction
7.​2 Selection Statements
7.​2.​1 if
7.​2.​2 if-else
7.​2.​3 switch
7.​3 Iteration Statements
7.​3.​1 while
7.​3.​2 do-while
7.​3.​3 for
Chapter 8:​Exercises
8.​1 Arithmetic Operations
8.​2 Integral Division
8.​3 Floating-Point Division and Casting
8.​4 Equality Operator
8.​5 Relational and Logical Operators
8.​6 The switch Statement
8.​7 Iteration Statements
Chapter 9:​Arrays
9.​1 Declaration
9.​2 Subscript Operator
9.​3 Array Initialization
9.​4 Character Arrays
9.​5 Multidimensional​Arrays
9.​6 Array Size and Count
Chapter 10:​Pointers
10.​1 Introduction
10.​2 Declaration and Initialization
10.​3 Pointers and Arrays
10.​4 Pointer Arithmetics
10.​5 Void Pointers
10.​6 Pointer to Character Arrays
10.​7 Arrays of Pointers
Chapter 11:​Command-Line Arguments
Chapter 12:​Exercises
12.​1 Character Array
12.​2 Array Elements
12.​3 Pointer to an Existing Object
12.​4 Pointers and Arrays
12.​5 Pointer to a Character Array
12.​6 Pointer Arithmetics
12.​7 Array of Pointers
Chapter 13:​Functions
13.​1 Introduction
13.​2 Function Declaration
13.​3 Function Definition
13.​4 Parameters and Arguments
13.​4.​1 Passing Arguments
13.​5 Return Statement
Chapter 14:​Exercises
14.​1 A Simple Function
14.​2 Function Declaration and Definition
14.​3 Passing Arguments by Value
14.​4 Passing Arguments by Pointer/​Address
14.​5 Function – Multiple Parameters
Chapter 15:​Structures
15.​1 Introduction
15.​2 Initialization
15.​3 Member Access Operator
15.​4 Copying Structures
15.​5 Pointers to Structures
15.​6 Self-Referencing Structures
15.​7 Structures as Function Arguments
Chapter 16:​Unions
Chapter 17:​Conditional Expression
Chapter 18:​Typedef
Chapter 19:​Const Qualifier
Chapter 20:​Enumerations
Chapter 21:​Function Pointers
Chapter 22:​Exercises
22.​1 Structure Definition
22.​2 Structure Typedef Alias
22.​3 Structure Initialization
22.​4 Pointers to Structures
22.​5 Unions
22.​6 Const Variables and Pointers
22.​7 Constant Function Parameters
22.​8 Enums
22.​9 Pointers to Functions
Chapter 23:​Preprocessor
23.​1 #include
23.​2 #define
23.​3 #undef
23.​4 Conditional Compilation
23.​4.​1 #if
23.​4.​2 #ifdef
23.​4.​3 #ifndef
23.​5 Built-in Macros
23.​6 Function-Like Macros
Chapter 24:​Exercises
24.​1 Define and Undefine a Macro
24.​2 Conditional Compilation
24.​3 Built-in Macros
24.​4 Function Macros
Chapter 25:​Dynamic Memory Allocation
25.​1 malloc
25.​2 calloc
25.​3 realloc
Chapter 26:​Storage and Scope
26.​1 Scope
26.​1.​1 Local Scope
26.​1.​2 Global Scope
26.​2 Storage
26.​2.​1 Automatic Storage Duration
26.​2.​2 Static Storage Duration
26.​2.​3 Allocated Storage Duration
Chapter 27:​Exercises
27.​1 Dynamic Memory Allocation
27.​2 Dynamic Memory Allocation:​Arrays
27.​3 Dynamic Memory Resizing
27.​4 Automatic and Allocated Storage
Chapter 28:​Standard Input and Output
28.​1 Standard Input
28.​1.​1 scanf
28.​1.​2 sscanf
28.​1.​3 fgets
28.​2 Standard Output
28.​2.​1 printf
28.​2.​2 puts
28.​2.​3 fputs
28.​2.​4 putchar
Chapter 29:​File Input and Output
29.​1 File Input
29.​2 File Output
Chapter 30:​Exercises
30.​1 Standard Input
30.​2 Standard Output
Chapter 31:​Header and Source Files
Part II: The C Standard Library
Chapter 32:​Introduction to C Standard Library
32.​1 String Manipulation
32.​1.​1 strlen
32.​1.​2 strcmp
32.​1.​3 strcat
32.​1.​4 strcpy
32.​1.​5 strstr
32.​2 Memory Manipulation Functions
32.​2.​1 memset
32.​2.​2 memcpy
32.​2.​3 memcmp
32.​2.​4 memchr
32.​3 Mathematical Functions
32.​3.​1 abs
32.​3.​2 fabs
32.​3.​3 pow
32.​3.​4 round
32.​3.​5 sqrt
32.​4 String Conversion Functions
32.​4.​1 strtol
32.​4.​2 snprintf
Part III: Modern C Standards
Chapter 33:​Introduction to C11 Standard
33.​1 _​Static_​assert
33.​2 The _​Noreturn Function Specifier
33.​3 Type Generic Macros Using _​Generic
33.​4 The _​Alignof Operator
33.​5 The _​Alignas Specifier
33.​6 Anonymous Structures and Unions
33.​7 Aligned Memory Allocation:​aligned_​alloc
33.​8 Unicode Support for UTF-16 and UTF-32
33.​9 Bounds Checking and Threads Overview
33.​9.​1 Bounds-Checking Functions
33.​9.​2 Threads Support
Chapter 34:​The C17 Standard
Chapter 35:​The Upcoming C2X Standard
35.​1 _​Static_​assert Without a Message
35.​2 Attributes
35.​3 No Parameters Function Declaration
35.​4 The strdup Function
35.​5 The memccpy Function
Part IV: Dos and Don’ts
Chapter 36:​Do Not Use the gets Function
Chapter 37:​Initialize Variables Before Using Them
Chapter 38:​Do Not Read Out of Bounds
Chapter 39:​Do Not Free the Allocated Memory Twice
Chapter 40:​Do Not Cast the Result of malloc
Chapter 41:​Do Not Overflow a Signed Integer
Chapter 42:​Cast a Pointer to void* When Printing Through printf
Chapter 43:​Do Not Divide by Zero
Chapter 44:​Where to Use Pointers?​
44.​1 Pointers to Existing Objects
44.​2 Pointers to Arrays
44.​3 Pointers to String Constants
44.​4 Pointers to Dynamically Allocated Memory
44.​5 Pointers as Function Arguments
Chapter 45:​Prefer Functions to Function-Like Macros
Chapter 46:​static Global Names
Chapter 47:​What to Put in Header Files?​
47.​1 Shared Macros
47.​2 Function Declarations
47.​3 Shared extern Variables and Constants
47.​4 Other Header Files
Part V: Appendices
Appendix A:​Linkage
Appendix B:​Time and Date
Appendix C:​Bitwise Operators
C.​1 The Bitwise NOT Operator ~
C.​2 Bitwise Shift Operators << and >>
C.​3 The Bitwise AND Operator &​
Appendix D:​Numeric Limits
D.​1 Integer Types Limits
D.​2 Floating-Point Types Limits
Appendix E:​Summary and Advice
E.​1 What to Learn Next?​
E.​2 Online References
E.​3 Other C Books
E.​4 Advice
Index
About the Author
Slobodan Dmitrović
is a software consultant, trainer, and
entrepreneur. He is the founder and CEO
of “Clear Programming Paradigm,” an
LLC that provides outsourcing and
training services. Slobodan’s ability to
summarize complex topics and provide
insightful training made him a sought-
after consultant for automotive, fintech,
and other industries. He has a strong
interest in C, C++, software architecture,
training, and R&D. Slobodan can be
reached at www.cppandfriends.com
.
About the Technical Reviewer
German Gonzalez-Morris
is a software architect/engineer working with C/C++, Java, and
different application containers, in particular, with WebLogic Server. He
has developed different applications including JEE/Spring/Python. His
areas also include OOP, Java/JEE, Python, design patterns, algorithms,
Spring Core/MVC/Security, and microservices. German has worked in
performance messaging, Restful API, and transactional systems. For
more, see www.linkedin.com/in/german-gonzalez-morris .
Part I
The C Programming Language
© Slobodan Dmitrović 2021
S. Dmitrović, Modern C for Absolute Beginners
https://doi.org/10.1007/978-1-4842-6643-4_1

1. Introduction
Slobodan Dmitrović 1
(1) Belgrade, Serbia

Dear reader, congratulations on choosing to learn the C programming


language, and thank you for picking up this book. My name is Slobodan
Dmitrović, and I will try to introduce you to a wonderful world of C
programming to the best of my abilities. This book is divided into four
parts. In Part 1, we cover the C language basics. Part 2 explains the C
standard library, and Part 3 introduces us to modern C standards. The
final part explains the dos and don’ts in modern C. Let us get started!

1.1 What Is C?
C is a programming language, a general-purpose, procedural, compiled
programming language. C language was created by Dennis Ritchie in
the late 1960s and early 1970s. The C program is a collection of C
source code spread across one or more source and header files. Source
files by convention have the .c extension, and header files have the .h
extension. Source and header files are plain text files that contain some
C code.

1.2 What Is C Used For?


C is often used for so-called systems programming, which is operating
systems programming, application programming, and embedded
systems programming, to name a few. A large portion of Linux and
Windows operating systems was programmed using C. C is often used
as a replacement for an assembly language. C language constructs
efficiently translate to the hardware itself. Whenever we want to get
down to the metal, we can opt for C.

1.3 C Compilers
To compile and run a C program, we need a C compiler. A compiler
compiles a C program and turns the source code into an object file. The
linker then links the object files together and produces an executable
file or a library, depending on our intention. For the most part, we say
we compile the program and assume the compilation process results in
an executable file that we can run. At the time of writing, some of the
more popular C compilers are:
gcc – as part of the GCC toolchain
Clang – as part of the LLVM toolchain
Visual C/C++ compiler – as part of the Visual Studio IDE
MinGW – a Windows port of the GCC

1.3.1 Installing Compilers


Here we describe how to install C compilers on Linux and Windows and
how to compile and run our programs.

1.3.1.1 On Linux
To install a GCC compiler on Linux , open a terminal window and type:

sudo apt install build-essential

This command installs a GCC toolchain, which we can use to


compile, debug, and run our C programs. Using a text editor of our
choice, let us create a file with the following code:

#include <stdio.h>

int main(void)
{
printf("Hello World!\n");
}
Let us save the file as a source.c. To compile this program using GCC,
we type:

gcc source.c

This will produce an executable file with a default name of a.out. To


run this file, type the following in a console window:

./a.out

Running this program should output the Hello World! string in


our console window.

Note For now, let us take the source code inside the source.c file for
granted. The example is for demonstration purposes. We will get into
detailed code explanation and analysis in later chapters.

To install a clang compiler on our Linux system, type:

sudo apt install clang

This command installs another compiler called Clang, which we can


also use to compile our programs. To compile our previous program
using a clang compiler, we type:

clang source.c

Same as before, the compiler compiles the source file and produces
an executable file with the default name of a.out. To run this file, we
type:

./a.out

The compiler choice is a matter of preference. Just substitute gcc


with clang and vice versa. To compile with warnings enabled, type:

gcc -Wall source.c


Warnings are not errors. They are messages indicating that
something in our program might lead to errors. We want to eliminate or
minimize the warnings as well.
To produce a custom executable name, add the -o flag, followed by
the custom executable name, so that our compilation string now looks
like:

gcc -Wall source.c -o myexe

To run the executable file, we now type:

./myexe

The ISO C standard governs the C programming language. There are


different versions of the C standard. We can target a specific C standard
by adding the -std= flag, followed by a standard name such as c99,
c11, or c17. To compile for a c99 standard, for example, we would
write:

gcc -std=c99 -Wall source.c

To compile for a C11 standard, we use:

gcc -std=c11 -Wall source.c

If we want to adhere to strict C standard rules, we add the -


pedantic compilation flag. This flag issues warnings if our code does
not comply with the strict C standard rules. Some of the use cases are:

gcc -std=c99 -Wall -pedantic source.c


gcc -std=c11 -Wall -pedantic source.c
gcc -std=c17 -Wall -pedantic source.c
gcc -std=c2x -Wall -pedantic source.c

To compile and run the program using a single statement, we type:

gcc source.c && ./a.out


This statement compiles the program and, if the compilation
succeeds, executes the a.out file.
Let us put it now all together and use the following compilation
strings in our future projects. If using gcc:

gcc -Wall -std=c11 -pedantic source.c && ./a.out

If using Clang:

clang -Wall -std=c11 -pedantic source.c && ./a.out

1.3.1.2 On Windows
On Windows , we can install Visual Studio. Choose the Create a new
project option, make sure the C++ option is selected, choose Empty
Project, and click Next. Modify the project and solution names or leave
the default values, and click Create. We have now created an empty
Visual Studio project. In the Solution Explorer window, right-click on a
project name and choose Add – New Item…. Ensure the Visual C++ tab is
selected, click on the C++ File (.cpp) option, modify the file name to
source.c, and click Add. We can use a different file name, but the
extension should be .c. Double-click on the source.c file, and paste our
previous Hello World source code into it. Press F5 to run the program.
To compile for the C11 standard, use the /std:c11 compiler switch.
To compile for the C17 standard, use the /std:c17 compiler switch.
Alternatively, install the MinGW (Minimalist GNU for Windows) and
use the compiler in a console window, the same way we would on
Linux.
So far, we have learned how to set up the programming
environments on Linux and Windows and compile and run our C
programs. We are now ready to start with the C theory and examples.

1.4 C Standards
The C programming language is a standardized language. There were
different C standards throughout history. The first notable standard
was the ANSI C, and now it is the ISO standard known as the
ISO/IEC:9989 standard. Some of the C standards throughout the years:
ANSI C Standard (referred to as ANSI C and C89)
C90 (official name: ISO/IEC 9899:1990; it is the ANSI C Standard
adopted by ISO; the C89 and C90 are the same things)
C99 (ISO/IEC 9899:1999)
C11 (ISO/IEC 9899:2011)
C17 (ISO/IEC 9899:2018)
The upcoming standard informally named C2x
Each of the standards introduces new features and changes to the
language and the standard library. Everything starting with C11 is often
referred to as the modern C. And modern C is what we will be teaching
in this book. Let us get started!
© Slobodan Dmitrović 2021
S. Dmitrović, Modern C for Absolute Beginners
https://doi.org/10.1007/978-1-4842-6643-4_2

2. Our First Program


Slobodan Dmitrović 1
(1) Belgrade, Serbia

This section describes the main program entry point, how to work with
comments, and how to write a simple “Hello World” program.

2.1 Function main()


Every C program that produces an executable file must have a starting
point. This starting point is the function main. The function main is the
function that gets called when we start our executable file. It is the
program’s main entry point. The signature of the function main is:

int main(void) {}

The function main is of type int, which stands for integer, followed
by the reserved name main, followed by an empty list of parameters
inside the parentheses (void). The name void inside the
parentheses means the function accepts no parameters. Following is
the function body marked with braces {}. The opening brace { marks
the beginning of a code block, and the closing brace } marks the end of
the code block. We write our C code inside the code block marked by
these braces. The code we write there executes when we start our
executable file.
For readability reasons, we can put braces on new lines:

int main(void)
{

}
We can keep the opening brace on the same line with the main
function definition and have the ending brace on a new line:

int main(void) {

Note Braces placement position is a matter of conventions,


preferences, and coding styles.

In early C standards, the function main was required to have a return


0; statement. This statement ends the program and returns control to
the operating system. The return value of 0 means the program
finished the execution as expected. It ended normally. If the main
function returns any value other than 0, it means the program ended
unexpectedly. So, in previous standards, our blank program would look
like:

int main(void)
{
return 0;
}

Statements in C end with a semicolon (;). The return 0;


statement within the main function is no longer required in modern C.
We can omit that statement. When the program execution reaches the
closing brace, the effect is the same as if we explicitly wrote the
statement. In modern standards, we can simply write:

int main(void)
{

}
We often see the use of the following, also valid main signature:

int main()
{
return 0;
}

While this signature indicates there are no parameters, in ANSI C, it


could potentially allow us to call the function with any number of
parameters. Since we want to avoid that, we will be using the int
main(void) signature, which explicitly states the function does not
accept parameters.
With that in mind, we will be using the following main skeleton to
write our code throughout the book:

int main(void)
{

Note There is another main signature accepting two parameters:


int main(int argc, char* argv[]). We will describe it
later in the book when we learn about arrays, pointers, and
character arrays.

2.2 Comments
We can have comments in our C program. A comment is a text that is
useful to us but is ignored by the compiler. Comments are used to
document the source code, serve as notes, or comment-out the part of
the source code.
A C-style comment starts with /* characters and ends with */
characters. The comment text is placed between these characters.
Example:

int main(void)
{
/* This is a comment in C */
}
The comment can also be a multiline comment:

int main(void)
{
/* This is a
multi-line comment in C */
}

Starting with C99, we can write a single-line comment that starts


with a double slash // followed by a comment text:

int main(void)
{
// This is a comment
}

We can have multiple single-line comments on separate lines:

int main(void)
{
// This is a comment
// This is another comment
}

Comments starting with the double slash // are also referred to as


C++ style comments.

2.3 Hello World


Let us write a simple program that outputs a “Hello World” message in
the console window and explain what each line of code does. The full
listing is:

#include <stdio.h>
Another Random Scribd Document
with Unrelated Content
CHAPTER XXIX
It is well known that the Patriarch Abraham was brought up in the
religion and the opinion of the Sabeans, that there is no divine being
except the stars. I will tell you in this chapter their works which are
at present extant in Arabic translations, and also in their ancient
chronicles; and I will show you their opinion and their practice
according to these books. You will then see clearly that they consider
the stars as deities, and the sun as the chief deity. They believe that
all the seven stars are gods, but the two luminaries are greater than
all the rest. They say distinctly that the sun governs the world, both
that which is above and that which is below; these are exactly their
expressions. In these books, and in their chronicles, the history of
Abraham our father is given in the following manner. Abraham was
brought up in Kutha; when he differed from the people and declared
that there is a Maker besides the sun, they raised certain objections,
and mentioned in their arguments the evident and manifest action of
the sun in the Universe. “You are right,” said Abraham; “[the sun
acts in the same manner] as ‘the axe in the hand of him that hews
with it.’ ” Then some of his arguments against his opponents are
mentioned. In short, the king put him in prison; but he continued
many days, while in prison, to argue against them. At last the king
was afraid that Abraham might corrupt the kingdom, and turn the
people away from their religion; he therefore expelled Abraham into
Syria, after having deprived him of all his property.

This is their account which you find clearly stated in the book called
The Nabatean Agriculture. Nothing is said there of the account given
in our trustworthy books, nor do they mention what he learnt by
way of prophecy; for they refused to believe him, because he
attacked their evil doctrine. I do not doubt that when he attacked
the doctrine of all his fellow-men, he was cursed, despised, and
scorned by these people who adhered to their erroneous opinions.
When he submitted to this treatment for the sake of God, as ought
to be done for the sake of His glory, God said to him, “And I will
bless them that bless thee, and curse them that curse thee” (Gen.
xii. 3). The result of the course which Abraham took, is the fact that
most people, as we see at present, agree in praising him, and being
proud of him; so that even those who are not his descendants call
themselves by his name. No one opposes him, and no one ignores
his merits, except some ignoble remnants of the nations left in the
remote corners of the earth, like the savage Turks in the extreme
North, and the Indians in the extreme South. These are remnants of
the Sabeans, who once filled the earth. [316]Those who were able to
think, and were philosophers in those days, could only raise
themselves to the idea that God is the spirit of the spheres; the
spheres with their stars being the body, and God the spirit. Abu-becr
al-Zaig mentions this in his Commentary on the book of Physics.

All the Sabeans thus believed in the eternity of the Universe, the
heavens being in their opinion God. Adam was in their belief a
human being born from male and female, like the rest of mankind;
he was only distinguished from his fellow-men by being a prophet
sent by the moon; he accordingly called men to the worship of the
moon, and he wrote several works on agriculture. The Sabeans
further relate that Noah was an agriculturist, and that he was not
pleased with the worship of idols; they blame him for that, and say
that he did not worship any image. In their writings we meet even
with the statement that Noah was rebuked and imprisoned because
he worshipped God, and with many other accounts about him. The
Sabeans contend that Seth differed from his father Adam, as regards
the worship of the moon. They manufactured ridiculous stories,
which prove that their authors were very deficient in knowledge,
that they were by no means philosophers, but on the contrary were
extremely ignorant persons. Adam, they say, left the torrid zone near
India and entered the region of Babylon, bringing with him
wonderful things, such as a golden tree, that was growing, and had
leaves and branches; a stone tree of the same kind, and a fresh leaf
of a tree proof against fire. He related that there was a tree which
could shelter ten thousand men, although it had only the height of a
man; two leaves he brought with him, each of which was sufficient
to cover two men. Of these stories the Sabeans have a wonderful
abundance. I am surprised that persons who think that the Universe
is eternal, can yet believe in these things which nature cannot
produce, as is known to every student of Natural Science. They only
mention Adam, and relate the above stories about him, in order to
support their theory of the Eternity of the Universe; from this theory
they then derive the doctrine that the stars and the spheres are
deities. When [Abraham] the “Pillar of the World” appeared, he
became convinced that there is a spiritual Divine Being, which is not
a body, nor a force residing in a body, but is the author of the
spheres and the stars; and he saw the absurdity of the tales in
which he had been brought up. He therefore began to attack the
belief of the Sabeans, to expose the falsehood of their opinions, and
to proclaim publicly in opposition to them, “the name of the Lord,
the God of the Universe” (Gen. xxi. 33), which proclamation included
at the same time the Existence of God, and the Creation of the
Universe by God.

In accordance with the Sabean theories images were erected to the


stars, golden images to the sun, images of silver to the moon, and
they attributed the metals and the climates to the influence of the
planets, saying that a certain planet is the god of a certain zone.
They built temples, placed in them images, and assumed that the
stars sent forth their influence upon these images, which are thereby
enabled (to speak) to understand, to comprehend, to inspire human
beings, and to tell them what is useful to them. They apply the same
to trees which fall to the lot of these stars. When, namely, a certain
tree, which is peculiar to a certain star, is dedicated to the name of
this star, and certain things are done for the tree and to the tree, the
[317]spiritual force of that star which influences that tree, inspires
men, and speaks to them when they are asleep. All this is written in
their works, to which I will call your attention. It applies to the
“prophets of Baal,” and the “prophets of Asherah,” mentioned in
Scripture, in whose hearts the Sabean theories had taken root, who
forsook God, and called, “Baal, hear us” (1 Kings xviii. 26); because
these theories were then general, ignorance had spread, and the
madness with which people adhered to this kind of imaginations had
increased in the world. When such opinions were adopted among
the Israelites, they had observers of clouds, enchanters, witches,
charmers, consulters with familiar spirits, wizards, and
necromancers.

We have shown in our large work, Mishneh-torah (Hilkot, ʻAbodah-


zarah i. 3), that Abraham was the first that opposed these theories
by argument and by soft and persuasive speech. He induced these
people, by showing kindness to them, to serve God. Afterwards
came the chief of the prophets and completed the work by the
commandment to slay those unbelievers, to blot out their name, and
to uproot them from the land of the living. Comp. “Ye shall destroy
their altars,” etc. (Exod. xxxiv. 13). He forbade us to follow their
ways; he said, “Ye shall not walk in the manners of the heathen,”
etc. (Lev. xx. 23). You know from the repeated declarations in the
Law that the principal purpose of the whole Law was the removal
and utter destruction of idolatry, and all that is connected therewith,
even its name, and everything that might lead to any such practices,
e.g., acting as a consulter with familiar spirits, or as a wizard,
passing children through the fire, divining, observing the clouds,
enchanting, charming, or inquiring of the dead. The law prohibits us
to imitate the heathen in any of these deeds, and a fortiori to adopt
them entirely. It is distinctly said in the Law that everything which
idolaters consider as service to their gods, and a means of
approaching them, is rejected and despised by God; comp. “for
every abomination to the Lord, which he hateth, have they done
unto their gods” (Deut. xii. 31). In the books which I shall name to
you later on, it is stated that on certain occasions they offered to the
sun, their greatest god, seven beetles, and seven mice, and seven
bats. This alone suffices to show how disgusting their practice must
be to human nature. Thus all precepts cautioning against idolatry, or
against that which is connected therewith, leads to it, or is related to
it, are evidently useful. They all tend to save us from the evil
doctrines that deprive us of everything useful for the acquisition of
the twofold perfection of man, by leading to those absurd practices
in which our fathers and ancestors have been brought up. Comp.
“And Joshua said unto all the people, Thus saith the Lord God of
Israel, your fathers dwelt on the other side of the river in old time,
even Terah, the father of Abraham, and the father of Nahor, and
they served other gods” (Josh. xxiv. 2). It is in reference to these
[idolatrous ideas] that the true prophets exclaim, “They walked after
[vain] things, which do not profit.” How great is the usefulness of
every precept that delivers us from this great error, and leads us
back to the true faith: that God, the Creator of all things, rules the
Universe; that He must be served, loved, and feared, and not those
imaginary deities. According to this faith we approach the true God,
and obtain His favour without having recourse to burdensome
means; for nothing else is required but to love and fear Him; this is
the aim in serving [318]God, as will be shown. Comp. “And now,
Israel, what doth the Lord thy God require of thee but to fear the
Lord”? etc. (Deut. x. 12). I shall complete this subject later on; now
let us return to the theme [of this chapter].

I say that my knowledge of the belief, practice, and worship of the


Sabeans has given me an insight into many of the divine precepts,
and has led me to know their reason. You will confirm it when I shall
give the reason of commandments which are seemingly purposeless.
I will mention to you the works from which you may learn all that I
know of the religion and the opinions of the Sabeans; you will
thereby obtain a true knowledge of my theory as regards the
purpose of the divine precepts.

The great book on this subject is the book On the Nabatean


Agriculture, translated by Ibn Wahshiya. In a succeeding chapter I
shall explain why the Sabeans had their religious doctrines written in
a work on agriculture. The book is full of the absurdities of idolatrous
people, and with those things to which the minds of the multitude
easily turn and adhere [perseveringly]; it speaks of talismans, the
means of directing the influence [of the stars]; witchcraft, spirits,
and demons that dwell in the wilderness. There occur also in this
book great absurdities, which are ridiculous in the eyes of intelligent
people. They were intended as a criticism and an attack on the
evident miracles by which all people learnt that there exists a God
who is judge over all people. Comp. “That thou mayest know how
that the earth is the Lord’s” (Exod. ix. 29), “That I am the Lord in
the midst of the earth” (ibid. viii. 18).

The book describes things as having been mentioned by Adam in his


book; a tree which is found in India, and has the peculiarity that any
branch taken from it and thrown to the ground creeps along and
moves like serpents; it also mentions a tree which in its root
resembles a human being, utters a loud sound, and speaks a word
or words; a plant is mentioned which has this peculiarity, that a leaf
of it put on the neck of a person conceals that person from the sight
of men, and enables him to enter or leave a place without being
seen, and if any part of it is burnt in open air a noise and terrible
sounds are heard whilst the smoke ascends. Numerous fables of this
kind are introduced in the description of the wonders of plants and
the properties of agriculture. This leads the author to argue against
the [true] miracles, and to say that they were the result of artifice.

Among other fables we read there that the plant althea, one of the
Asherot, which they made, as I told you, stood in Nineveh twelve
thousand years. This tree had once a quarrel with the mandragora,
which wanted to take the place of the former. The person who had
been inspired by this tree ceased to receive inspiration; when after
some time the prophetical power had returned to him, he was told
by the althea that the latter had been engaged in a dispute with the
mandragora. He was then commanded to write to the magicians that
they should decide whether the althea or the mandragora was better
and more effective in witchcraft. It is a long story, and you may
learn from it, when you read it, the opinions and the wisdom of the
men of that time. Such were in those days of darkness the wise men
of Babel, to whom reference is made in Scripture, and such were the
beliefs in which they were trained. And were it not that the theory of
the Existence [319]of God is at present generally accepted, our days
would now have been darker than those days, though in other
respects. I return now to my subject.

In that book the following story is also related: One of the idolatrous
prophets, named Tammuz, called upon the king to worship the
seven planets and the twelve constellations of the Zodiac;
whereupon the king killed him in a dreadful manner. The night of his
death the images from all parts of the land came together in the
temple of Babylon which was devoted to the image of the Sun, the
great golden image. This image, which was suspended between
heaven and earth, came down into the midst of the temple, and
surrounded by all other images commenced to mourn for Tammuz,
and to relate what had befallen him. All other images cried and
mourned the whole night; at dawn they flew away and returned to
their temples in every corner of the earth. Hence the regular custom
arose for the women to weep, lament, mourn, and cry for Tammuz
on the first day of the month of Tammuz.

Consider what opinions people had in these days. The legend of


Tammuz is very old among the Sabeans. This book will disclose to
you most of the perverse ideas and practices of the Sabeans,
including their feasts. But you must be careful and must not be
misled to think that we have real incidents in the life of Adam, or of
any other person, or any real fact in the stories which they relate
about Adam, the serpent, the tree of knowledge of good and evil,
and the allusion to the garment of Adam which he had not been
accustomed to wear. A little consideration will lay open the falsehood
of all these accounts; it will show that they have been invented in
imitation of the Pentateuch when it became known among the
nations. The account of the Creation was heard, and it was taken
entirely in its literal sense. They have done this in order that the
ignorant may hear it, and be persuaded to assume the Eternity of
the Universe, and to believe that the Scriptural account contained
facts which happened in the manner as has been assumed by the
Sabeans.

It is by no means necessary to point this out to men like you. You


have acquired sufficient knowledge to keep your mind free from the
absurdities of the Kasdim, Chaldeans, and Sabeans, who are bare of
every true science. But I wish to exhort you that you should caution
others, for ordinary people are very much inclined to believe these
fables.

To the same class of books we count the book Istimachis, attributed


to Aristotle, who can by no means have been its author; also the
books on Talismans, such as the book of Tomtom; the book al-Sarb;
the book on the degrees of the sphere and the constellations rising
with each degree; a book on Talismans attributed to Aristotle, a
book ascribed to Hermes, a book of the Sabean Isḥak in defence of
the Sabean religion, and his large work on Sabean customs, details
of their religion, ceremonies, festivals, offerings, prayers and other
things relating to their faith.

All these books which I have mentioned are works on idolatry


translated into Arabic; there is no doubt that they form a very small
portion in comparison to that which has not been translated, and
that which is no longer extant, but has been lost in the course of
time. But those works which are at present extant, include most of
the opinions of the Sabeans and their practices, which are to some
degree still in vogue in the world. [320]

They describe how temples are built and images of metal and stone
placed in them, altars erected and sacrifices and various kinds of
food are offered thereon, festivals celebrated, meetings held in the
temples for prayer and other kinds of service; how they select
certain very distinguished places and call them temples of
Intellectual Images (or Forms); how they make images “on the high
mountains” (Deut. xii. 2), rear asherot, erect pillars, and do many
other things which you can learn from the books mentioned by us.
The knowledge of these theories and practices is of great
importance in explaining the reasons of the precepts. For it is the
principal object of the Law and the axis round which it turns, to blot
out these opinions from man’s heart and make the existence of
idolatry impossible. As regards the former Scripture says: “Lest your
heart be persuaded,” etc. (Deut. xi. 16), “whose heart turneth away
to-day,” etc. (ibid. xxix. 17). The actual abolition of idolatry is
expressed in the following passage: “Ye shall destroy their altars,
and burn their groves in fire” (Deut. vii. 5), “and ye shall destroy
their name,” etc. (xii. 3). These two things are frequently repeated;
they form the principal and first object of the whole Law, as our
Sages distinctly told us in their traditional explanation of the words
“all that God commanded you by the hand of Moses” (Num. xv. 23);
for they say, “Hence we learn that those who follow idolatry deny as
it were their adhesion to the whole Law, and those who reject
idolatry follow as it were the whole Law.” (B. T. Kidd, 40a.) Note it.

[Contents]
CHAPTER XXX
On examining these old and foolish doctrines we find that it was
most generally believed by the people that by the worship of stars
the earth will become inhabited, and the ground fertilized. The wise,
pious, and sin-fearing men among them reproved the people and
taught them that agriculture, on which the preservation of mankind
depended, would become perfect and satisfy man’s wishes, when he
worshipped the sun and the stars. If man provoked these beings by
his rebelliousness, the towns would become empty and waste. In
the above-named books it is stated that Mars was angry with [lands,
that form now] deserts and wastes, and in consequence of that
anger they were deprived of water and trees, and have become the
habitation of demons. Tillers of the ground and husbandmen are
praised in those books, because they are engaged with the
cultivation of the land in accordance with the will and desire of the
stars. The idolaters also held cattle in esteem on account of their use
in agriculture, and went even so far as to say, that it is not allowed
to slay them, because they combine in themselves strength and
willingness to do the work of man in tilling the ground. The oxen,
notwithstanding their great strength, do this, and submit to man,
because it is the will of God that they should be employed in
agriculture. When these views became generally known, idolatry was
connected with agriculture, because the latter is indispensable for
the maintenance of man, and of most animals. The idolatrous priests
then preached to the people who met in the temples, and taught
them that by certain religious acts, rain would come down, the trees
of the field would yield their fruit, and the land would be fertile and
inhabited. See what is said in the [321]Nabatean Agriculture in the
chapter on vineyards. The following words of the Sabeans are
quoted there: “All ancient wise men advised, and prophets likewise
commanded and enjoined to play before the images on certain
instruments during the festivals. They also said—and what they said
is true—that the deities are pleased with it, and reward those who
do it. They promise, indeed, very great reward for these things; e.g.,
length of life, protection from illness, exemption from great bodily
deformities, plenty of the produce of the earth, and of the fruits of
the trees.” These are the words of the Sabeans. When these ideas
spread, and were considered as true, God, in His great mercy for us,
intended to remove this error from our minds, and to protect our
bodies from trouble; and therefore desired us to discontinue the
practice of these useless actions. He gave us His Law through
Moses, our teacher, who told us in the name of God, that the
worship of stars and other corporeal beings would effect that rain
would cease, the land be waste, and would not produce anything,
and the fruit of the trees would wither; calamities would befall the
people, their bodies would be deformed, and life would be
shortened. These are the contents of “the words of the covenant
which God made” (Deut. xxviii. 6–9). It is frequently expressed in all
parts of Scripture, that the worship of the stars would be followed by
absence of rain, devastation of the land, bad times, diseases, and
shortness of life. But abandonment of that worship, and the return
to the service of God, would be the cause of the presence of rain,
fertility of the ground, good times, health and length of life. Thus
Scripture teaches, in order that man should abandon idolatry, the
reverse of that which idolatrous priests preached to the people, for,
as has been shown by us, the principal object of the Law is to
remove this doctrine, and to destroy its traces.

[Contents]
CHAPTER XXXI
There are persons who find it difficult to give a reason for any of the
commandments, and consider it right to assume that the
commandments and prohibitions have no rational basis whatever.
They are led to adopt this theory by a certain disease in their soul,
the existence of which they perceive, but which they are unable to
discuss or to describe. For they imagine that these precepts, if they
were useful in any respect, and were commanded because of their
usefulness, would seem to originate in the thought and reason of
some intelligent being. But as things which are not objects of reason
and serve no purpose, they would undoubtedly be attributed to God,
because no thought of man could have produced them. According to
the theory of those weak-minded persons, man is more perfect than
his Creator. For what man says or does has a certain object, whilst
the actions of God are different; He commands us to do what is of
no use to us, and forbids us to do what is harmless. Far be this! On
the contrary, the sole object of the Law is to benefit us. Thus we
explained the Scriptural passage, “for our good always, that He
might preserve us alive, as it is this day” (Deut. vi. 24). Again,
“which shall hear all those statutes (ḥuḳḳim), and say, surely this
great nation is a wise and understanding people” (ibid. iv. 6). He
thus says that even every one of these “statutes” convinces all
nations of the wisdom and understanding it includes. But if no
reason could be found for [322]these statutes, if they produced no
advantage and removed no evil, why then should he who believes in
them and follows them be wise, reasonable, and so excellent as to
raise the admiration of all nations? But the truth is undoubtedly as
we have said, that every one of the six hundred and thirteen
precepts serves to inculcate some truth, to remove some erroneous
opinion, to establish proper relations in society, to diminish evil, to
train in good manners, or to warn against bad habits. All this
depends on three things: opinions, morals, and social conduct. We
do not count words, because precepts, whether positive or negative,
if they relate to speech, belong to those precepts which regulate our
social conduct, or to those which spread truth, or to those which
teach morals. Thus these three principles suffice for assigning a
reason for every one of the Divine commandments.

[Contents]
CHAPTER XXXII
On considering the Divine acts, or the processes of Nature, we get
an insight into the prudence and wisdom of God as displayed in the
creation of animals, with the gradual development of the movements
of their limbs and the relative positions of the latter, and we perceive
also His wisdom and plan in the successive and gradual development
of the whole condition of each individual. The gradual development
of the animals’ movements and the relative position of the limbs may
be illustrated by the brain. The front part is very soft, the back part
is a little hard, the spinal marrow is still harder, and the farther it
extends the harder it becomes. The nerves are the organs of
sensation and motion. Some nerves are only required for sensation,
or for slight movements, as, e.g., the movement of the eyelids or of
the jaws; these nerves originate in the brain. The nerves which are
required for the movements of the limbs come from the spinal
marrow. But nerves, even those that come directly from the spinal
cord, are too soft to set the joints in motion; therefore God made
the following arrangement: the nerves branch out into fibres which
are covered with flesh, and become muscles; the nerves that come
forth at the extremities of the muscles and have already commenced
to harden, and to combine with hard pieces of ligaments, are the
sinews which are joined and attached to the limbs. By this gradual
development the nerves are enabled to set the limbs in motion. I
quote this one instance because it is the most evident of the
wonders described in the book On the use of the limbs; but the use
of the limbs is clearly perceived by all who examine them with a
sharp eye. In a similar manner did God provide for each individual
animal of the class of mammalia. When such an animal is born it is
extremely tender, and cannot be fed with dry food. Therefore
breasts were provided which yield milk, and the young can be fed
with moist food which corresponds to the condition of the limbs of
the animal, until the latter have gradually become dry and hard.

Many precepts in our Law are the result of a similar course adopted
by the same Supreme Being. It is, namely, impossible to go suddenly
from one extreme to the other; it is therefore according to the
nature of man impossible for him suddenly to discontinue everything
to which he has been accustomed. Now God sent Moses to make
[the Israelites] a kingdom of priests and a holy nation (Exod. xix. 6)
by means of the knowledge of God. [323]Comp. “Unto thee it was
showed that thou mightest know that the Lord is God” (Deut. iv.
35); “Know therefore this day, and consider it in thine heart, that the
Lord is God” (ibid. v. 39). The Israelites were commanded to devote
themselves to His service; comp. “and to serve him with all your
heart” (ibid. xi. 13); “and you shall serve the Lord your God” (Exod.
xxiii. 25); “and ye shall serve him” (Deut. xiii. 5). But the custom
which was in those days general among all men, and the general
mode of worship in which the Israelites were brought up, consisted
in sacrificing animals in those temples which contained certain
images, to bow down to those images, and to burn incense before
them; religious and ascetic persons were in those days the persons
that were devoted to the service in the temples erected to the stars,
as has been explained by us. It was in accordance with the wisdom
and plan of God, as displayed in the whole Creation, that He did not
command us to give up and to discontinue all these manners of
service; for to obey such a commandment it would have been
contrary to the nature of man, who generally cleaves to that to
which he is used; it would in those days have made the same
impression as a prophet would make at present if he called us to the
service of God and told us in His name, that we should not pray to
Him, not fast, not seek His help in time of trouble; that we should
serve Him in thought, and not by any action. For this reason God
allowed these kinds of service to continue; He transferred to His
service that which had formerly served as a worship of created
beings, and of things imaginary and unreal, and commanded us to
serve Him in the same manner; viz., to build unto Him a temple;
comp. “And they shall make unto me a sanctuary” (Exod. xxv. 8); to
have the altar erected to His name; comp. “An altar of earth thou
shalt make unto me” (ibid. xx. 21); to offer the sacrifices to Him;
comp. “If any man of you bring an offering unto the Lord” (Lev. i. 2),
to bow down to Him and to burn incense before Him. He has
forbidden to do any of these things to any other being; comp. “He
who sacrificeth unto any God, save the Lord only, he shall be utterly
destroyed” (Exod. xxii. 19); “For thou shalt bow down to no other
God” (ibid. xxxiv. 14). He selected priests for the service in the
temple; comp. “And they shall minister unto me in the priest’s office”
(ibid. xxviii. 41). He made it obligatory that certain gifts, called the
gifts of the Levites and the priests, should be assigned to them for
their maintenance while they are engaged in the service of the
temple and its sacrifices. By this Divine plan it was effected that the
traces of idolatry were blotted out, and the truly great principle of
our faith, the Existence and Unity of God, was firmly established;
this result was thus obtained without deterring or confusing the
minds of the people by the abolition of the service to which they
were accustomed and which alone was familiar to them. I know that
you will at first thought reject this idea and find it strange; you will
put the following question to me in your heart: How can we suppose
that Divine commandments, prohibitions, and important acts, which
are fully explained, and for which certain seasons are fixed, should
not have been commanded for their own sake, but only for the sake
of some other thing; as if they were only the means which He
employed for His primary object? What prevented Him from making
His primary object a direct commandment to us, and to give us the
capacity of obeying it? Those precepts which in your opinion are only
the means and not the [324]object would then have been
unnecessary. Hear my answer, which will cure your heart of this
disease and will show you the truth of that which I have pointed out
to you. There occurs in the Law a passage which contains exactly
the same idea; it is the following: “God led them not through the
way of the land of the Philistines, although that was near; for God
said, Lest peradventure the people repent when they see war, and
they return to Egypt; but God led the people about, through the way
of the wilderness of the Red Sea,” etc. (Exod. xiii. 17). Here God led
the people about, away from the direct road which He originally
intended, because He feared they might meet on that way with
hardships too great for their ordinary strength; He took them by
another road in order to obtain thereby His original object. In the
same manner God refrained from prescribing what the people by
their natural disposition would be incapable of obeying, and gave the
above-mentioned commandments as a means of securing His chief
object, viz., to spread a knowledge of Him [among the people], and
to cause them to reject idolatry. It is contrary to man’s nature that
he should suddenly abandon all the different kinds of Divine service
and the different customs in which he has been brought up, and
which have been so general, that they were considered as a matter
of course; it would be just as if a person trained to work as a slave
with mortar and bricks, or similar things, should interrupt his work,
clean his hands, and at once fight with real giants. It was the result
of God’s wisdom that the Israelites were led about in the wilderness
till they acquired courage. For it is a well-known fact that travelling
in the wilderness, and privation of bodily enjoyments, such as
bathing, produce courage, whilst the reverse is the source of faint-
heartedness; besides, another generation rose during the
wanderings that had not been accustomed to degradation and
slavery. All the travelling in the wilderness was regulated by Divine
commands through Moses; comp. “At the commandment of the Lord
they rested, and at the commandment of the Lord they journeyed;
they kept the charge of the Lord and the commandment of the Lord
by the hand of Moses” (Num. ix. 23). In the same way the portion of
the Law under discussion is the result of divine wisdom, according to
which people are allowed to continue the kind of worship to which
they have been accustomed, in order that they might acquire the
true faith, which is the chief object [of God’s commandments]. You
ask, What could have prevented God from commanding us directly,
that which is the chief object, and from giving us the capacity of
obeying it? This would lead to a second question, What prevented
God from leading the Israelites through the way of the land of the
Philistines, and endowing them with strength for fighting? The
leading about by a pillar of cloud by day and a pillar of fire by night
would then not have been necessary. A third question would then be
asked in reference to the good promised as reward for the keeping
of the commandments, and the evil foretold as a punishment for
sins. It is the following question: As it is the chief object and
purpose of God that we should believe in the Law, and act according
to that which is written therein, why has He not given us the
capacity of continually believing in it, and following its guidance,
instead of holding out to us reward for obedience, and punishment
for disobedience, or of actually giving all the predicted reward and
punishment? For [the promises and the threats] are [325]but the
means of leading to this chief object. What prevented Him from
giving us, as part of our nature, the will to do that which He desires
us to do, and to abandon the kind of worship which He rejects?
There is one general answer to these three questions, and to all
questions of the same character; it is this: Although in every one of
the signs [related in Scripture] the natural property of some
individual being is changed, the nature of man is never changed by
God by way of miracle. It is in accordance with this important
principle that God said, “O that there were such an heart in them,
that they would fear me,” etc. (Deut. v. 26). It is also for this reason
that He distinctly stated the commandments and the prohibitions,
the reward and the punishment. This principle as regards miracles
has been frequently explained by us in our works; I do not say this
because I believe that it is difficult for God to change the nature of
every individual person; on the contrary, it is possible, and it is in His
power, according to the principles taught in Scripture; but it has
never been His will to do it, and it never will be. If it were part of His
will to change [at His desire] the nature of any person, the mission
of prophets and the giving of the Law would have been altogether
superfluous.

I now return to my theme. As the sacrificial service is not the


primary object [of the commandments about sacrifice], whilst
supplications, prayers, and similar kinds of worship are nearer to the
primary object, and indispensable for obtaining it, a great difference
was made in the Law between these two kinds of service. The one
kind, which consists in offering sacrifices, although the sacrifices are
offered to the name of God, has not been made obligatory for us to
the same extent as it had been before. We were not commanded to
sacrifice in every place, and in every time, or to build a temple in
every place, or to permit any one who desires to become priest and
to sacrifice. On the contrary, all this is prohibited unto us. Only one
temple has been appointed, “in the place which the Lord shall
choose” (Deut. xii. 26); in no other place is it allowed to sacrifice;
comp. “Take heed to thyself, that thou offer not thy burnt-offerings
in every place that thou seest” (ibid. v. 13); and only the members
of a particular family were allowed to officiate as priests. All these
restrictions served to limit this kind of worship, and keep it within
those bounds within which God did not think it necessary to abolish
sacrificial service altogether. But prayer and supplication can be
offered everywhere and by every person. The same is the case with
the commandment of ẓiẓit (Num. xv. 38); mezuzah (Deut. vi. 9; xi.
20); tefillin (Exod. xiii. 9, 16); and similar kinds of divine service.

Because of this principle which I explained to you, the Prophets in


their books are frequently found to rebuke their fellow-men for being
over-zealous and exerting themselves too much in bringing
sacrifices; the prophets thus distinctly declared that the object of the
sacrifices is not very essential, and that God does not require them.
Samuel therefore said, “Hath the Lord as great delight in burnt-
offerings and sacrifices as in obeying the voice of the Lord” (1 Sam.
xv. 22)? Isaiah exclaimed, “To what purpose is the multitude of your
sacrifices unto me? saith the Lord” (Isa. i. 11); Jeremiah declared:
“For I spake not unto your fathers, nor commanded them in the day
that I brought them out of the land of Egypt, concerning burnt-
offerings or sacrifices. But this thing commanded I them, saying,
Obey my voice, and [326]I will be your God, and ye shall be my
people” (Jer. vii. 22, 23). This passage has been found difficult in the
opinion of all those whose words I read or heard; they ask, How can
Jeremiah say that God did not command us about burnt-offering and
sacrifice, seeing so many precepts refer to sacrifice? The sense of
the passage agrees with what I explained to you. Jeremiah says [in
the name of God] the primary object of the precepts is this, Know
me, and serve no other being; “I will be your God, and ye shall be
my people” (Lev. xxvi. 12). But the commandment that sacrifices
shall be brought and that the temple shall be visited has for its
object the success of that principle among you; and for its sake I
have transferred these modes of worship to my name; idolatry shall
thereby be utterly destroyed, and Jewish faith firmly established.
You, however, have ignored this object, and taken hold of that which
is only the means of obtaining it; you have doubted my existence,
“ye have denied the Lord, and said he is not” (Jer. v. 12); ye served
idols; “burnt incense unto Baal, and walked after other gods whom
ye know not. And come and stand before me in this house” (ibid. vii.
9–10); i.e., you do not go beyond attending the temple of the Lord,
and offering sacrifices; but this is not the chief object.—I have
another way of explaining this passage with exactly the same result.
For it is distinctly stated in Scripture, and handed down by tradition,
that the first commandments communicated to us did not include
any law at all about burnt-offering and sacrifice. You must not see
any difficulty in the Passover which was commanded in Egypt; there
was a particular and evident reason for that, as will be explained by
me (chap. xlvi.). Besides it was revealed in the land of Egypt; whilst
the laws to which Jeremiah alludes in the above passage are those
which were revealed after the departure from Egypt. For this reason
it is distinctly added, “in the day that I brought them out from the
land of Egypt.” The first commandment after the departure from
Egypt was given at Marah, in the following words, “If thou wilt
diligently hearken to the voice of the Lord thy God, and wilt do that
which is right in His sight, and wilt give ear to His commandments”
(Exod. xv. 26). “There he made for them a statute and an ordinance,
and there he proved them” (ibid. ver. 25). According to the true
traditional explanation, Sabbath and civil laws were revealed at
Marah; “statute” alludes to Sabbath, and “ordinance” to civil laws,
which are the means of removing injustice. The chief object of the
Law, as has been shown by us, is the teaching of truths; to which
the truth of the creatio ex nihilo belongs. It is known that the object
of the law of Sabbath is to confirm and to establish this principle, as
we have shown in this treatise (Part II. chap. xxxi.). In addition to
the teaching of truths the Law aims at the removal of injustice from
mankind. We have thus proved that the first laws do not refer to
burnt-offering and sacrifice, which are of secondary importance. The
same idea which is contained in the above passage from Jeremiah is
also expressed in the Psalms, where the people are rebuked that
they ignore the chief object, and make no distinction between chief
and subsidiary lessons. The Psalmist says: “Hear, O my people, and I
will speak; O Israel, and I will testify against thee: I am God, even
thy God. I will not reprove thee for thy sacrifices or thy burnt-
offerings, they have been continually before me. I will take no
bullock out of thy house, nor he-goats out of thy folds” (Ps. l.
[327]29).—Wherever this subject is mentioned, this is its meaning.
Consider it well, and reflect on it.
[Contents]
CHAPTER XXXIII
It is also the object of the perfect Law to make man reject, despise,
and reduce his desires as much as is in his power. He should only
give way to them when absolutely necessary. It is well known that it
is intemperance in eating, drinking, and sexual intercourse that
people mostly rave and indulge in; and these very things counteract
the ulterior perfection of man, impede at the same time the
development of his first perfection, and generally disturb the social
order of the country and the economy of the family. For by following
entirely the guidance of lust, in the manner of fools, man loses his
intellectual energy, injures his body, and perishes before his natural
time; sighs and cares multiply; there is an increase of envy, hatred,
and warfare for the purpose of taking what another possesses. The
cause of all this is the circumstance that the ignorant considers
physical enjoyment as an object to be sought for its own sake. God
in His wisdom has therefore given us such commandments as would
counteract that object, and prevent us altogether from directing our
attention to it, and has debarred us from everything that leads only
to excessive desire and lust. This is an important thing included in
the objects of our Law. See how the Law commanded to slay a
person from whose conduct it is evident that he will go too far in
seeking the enjoyment of eating and drinking. I mean “the rebellious
and stubborn son”; he is described as “a glutton and a drunkard”
(Deut. xxi. 20). The Law commands to stone him and to remove him
from society lest he grow up in this character, and kill many, and
injure the condition of good men by his great lust.

Politeness is another virtue promoted by the Law. Man shall listen to


the words of his neighbour; he shall not be obstinate, but shall yield
to the wish of his fellow-men, respond to their appeal, act according
to their desire, and do what they like. Thus the Law commands,
“Circumcise therefore the foreskin of your heart, and be no more
stiff-necked” (Deut. x. 16); “Take heed and hearken” (ibid. xxvii. 9).
“If you be willing and obedient” (Isa. i. 19). Those who listen [to the
words of others] and accept as much as is right are represented as
saying, “We will hear and do” (Deut. v. 24), or in a figurative style,
“Draw me, we will run after thee” (Song i. 4).

The Law is also intended to give its followers purity and holiness; by
teaching them to suppress sensuality, to guard against it and to
reduce it to a minimum, as will be explained by us. For when God
commanded [Moses] to sanctify the people for the receiving of the
Law, and said, “Sanctify them to-day and to-morrow” (Exod. xix.
10), Moses [in obedience to this command] said to the people,
“Come not at your wives” (ibid. ver. 15). Here it is clearly stated that
sanctification consists in absence of sensuality. But abstinence from
drinking wine is also called holiness; in reference to the Nazarite it is
therefore said, “He shall be holy” (Num. vi. 5). According to Siphra
the words, “sanctify yourselves and be ye holy” (Lev. xx. 7), refer to
the sanctification effected by performing the divine commands. As
the obedience to such precepts as have been mentioned above is
called by [328]the Law sanctification and purification, so is defilement
applied to the transgression of these precepts and the performance
of disgraceful acts, as will be shown. Cleanliness in dress and body
by washing and removing sweat and dirt is included among the
various objects of the Law, but only if connected with purity of
action, and with a heart free from low principles and bad habits. It
would be extremely bad for man to content himself with a purity
obtained by washing and cleanliness in dress, and to be at the same
time voluptuous and unrestrained in food and lust. These are
described by Isaiah as follows: “They that sanctify themselves and
purify themselves in the gardens, but continue their sinful life, when
they are in the innermost [of their houses], eating swine’s flesh, and
the abomination, and the mouse” (Isa. lxvi. 17): that is to say, they
purify and sanctify themselves outwardly as much as is exposed to
the sight of the people, and when they are alone in their chambers
and the inner parts of their houses, they continue their
rebelliousness and disobedience, and indulge in partaking of
forbidden food, such as [the flesh of] swine, worms, and mice. The
prophet alludes perhaps in the phrase “behind one tree in the midst”
to indulgence in forbidden lust. The sense of the passage is
therefore this: They appear outwardly clean, but their heart is bent
upon their desires and bodily enjoyments, and this is contrary to the
spirit of the Law. For the chief object of the Law is to [teach man to]
diminish his desires, and to cleanse his outer appearance after he
has purified his heart. Those who wash their body and cleanse their
garments whilst they remain dirty by bad actions and principles, are
described by Solomon as “a generation that are pure in their own
eyes, and yet are not washed from their filthiness; a generation, oh
how lofty are their eyes!” etc. (Prov. xxx. 12–13). Consider well the
principles which we mentioned in this chapter as the final causes of
the Law; for there are many precepts, for which you will be unable
to give a reason unless you possess a knowledge of these principles,
as will be explained further on.

[Contents]
CHAPTER XXXIV
It is also important to note that the Law does not take into account
exceptional circumstances; it is not based on conditions which rarely
occur. Whatever the Law teaches, whether it be of an intellectual, a
moral, or a practical character, is founded on that which is the rule
and not on that which is the exception; it ignores the injury that
might be caused to a single person through a certain maxim or a
certain divine precept. For the Law is a divine institution, and [in
order to understand its operation] we must consider how in Nature
the various forces produce benefits which are general, but in some
solitary cases they cause also injury. This is clear from what has
been said by ourselves as well as by others. We must consequently
not be surprised when we find that the object of the Law does not
fully appear in every individual; there must naturally be people who
are not perfected by the instruction of the Law, just as there are
beings which do not receive from the specific forms in Nature all that
they require. For all this comes from one God, is the result of one
act; “they are all given from one shepherd” (Eccles. xii. 11). It is
impossible to be otherwise; and we have already explained (chap.
xv.) that that which is impossible always remains [329]impossible and
never changes. From this consideration it also follows that the laws
cannot like medicine vary according to the different conditions of
persons and times; whilst the cure of a person depends on his
particular constitution at the particular time, the divine guidance
contained in the Law must be certain and general, although it may
be effective in some cases and ineffective in others. If the Law
depended on the varying conditions of man, it would be imperfect in
its totality, each precept being left indefinite. For this reason it would
not be right to make the fundamental principles of the Law
dependent on a certain time or a certain place; on the contrary, the
statutes and the judgments must be definite, unconditional, and
general, in accordance with the divine words: “As for the
congregation, one ordinance shall be for you and for the stranger”
(Num. xv. 15); they are intended, as has been stated before, for all
persons and for all times.

After having premised these introductory remarks I will now proceed


to the exposition of that which I intended to explain.

[Contents]
CHAPTER XXXV
In accordance with this intention I find it convenient to divide all
precepts into fourteen classes.

The first class comprises those precepts which form fundamental


principles, such as we have enumerated in Hilkot yesode ha-torah.
Repentance and fasts belong also to this class, as will be shown.

The second class comprises the precepts which are connected with
the prohibition of idolatry, and which have been described by us in
Hilkot aʻbodah-zarah. The laws concerning garments of linen and
wool, concerning the fruit of trees in the first three years after they
have been planted, and concerning divers seeds in a vineyard, are
likewise contained in this class. The object of these precepts is to
establish certain true principles and to perpetuate them among the
people.

The third class is formed by commandments which are connected


with the improvement of the moral condition [of mankind]; these are
mentioned in Hilkot deʻot. It is known that by a good moral state
those social relations, which are indispensable for the well-being of
mankind, are brought to perfection.

The fourth class includes precepts relating to charity, loans, gifts,


and the like, e.g., the rules respecting “valuations,” (scil., of things
devoted to sacred purposes, Lev. xxvii. 1–27); “things devoted”
(ibid. ver. 28); laws concerning loans and servants, and all the laws
enumerated in the section Zeraʻim, except the rules of “mixtures”
and “the fruit of trees in the first three years.” The object of these
precepts is clear; their benefit concerns all people by turns; for he
who is rich to-day may one day be poor—either he himself or his
descendants; and he who is now poor, he himself or his son may be
rich to-morrow.

The fifth class contains those precepts which relate to the prevention
of wrong and violence; they are included in our book in the section
Neziḳin. Their beneficial character is evident.

The sixth class is formed of precepts respecting fines, e.g., the laws
on theft and robbery, on false witnesses, and most of the laws
contained in the [330]section Shofetim belong to this class. Their
benefit is apparent; for if sinners and robbers were not punished,
injury would not be prevented at all: and persons scheming evil
would not become rarer. They are wrong who suppose that it would
be an act of mercy to abandon the laws of compensation for
injuries; on the contrary, it would be perfect cruelty and injury to the
social state of the country. It is an act of mercy that God
commanded “judges and officers thou shalt appoint to thee in all thy
gates” (Deut. xvi. 18).

The seventh class comprises those laws which regulate the business
transactions of men with each other; e.g., laws about loans, hire,
trust, buying, selling, and the like; the rules about inheritance
belong to this class. We have described these precepts in the
sections Ḳinyan and Mishpatim. The object of these precepts is
evident, for monetary transactions are necessary for the peoples of
all countries, and it is impossible to have these transactions without
a proper standard of equity and without useful regulations.

The eighth class includes those precepts which relate to certain


days, as Sabbaths and holydays; they are enumerated in the section
Zemannim. The Law states clearly the reason and object of each of
these precepts; they are to serve as a means for establishing a
certain principle among us, or securing bodily recreation, or effecting
both things at the same time, as will be shown by me.
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!

ebooknice.com

You might also like