没有合适的资源?快使用搜索试试~ 我知道了~
C - Modern C - Jens Gustedt
0 下载量 39 浏览量
2024-06-18
13:42:06
上传
评论
收藏 3.08MB PDF 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/89449848/0001-d9b87e2d44c6a10484391cf2206834ba_thumbnail.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
325页
Contents About this book i C versions i C and C++ ii Requirements ii Source code iii Exercises and challenges iii Organization iii Author iv Level 0. Encounter 1 1. Getting started 2 1.1. Imperative programming 2 1.2. Compiling and running 4 Summary 7 2. The principal structure of a program 8 2.1. Grammar 8 2.2. Declarations 9 2.3. Definitions 11 2.4. Statements 13 Summary 15
资源推荐
资源详情
资源评论
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/release/download_crawler_static/89449848/bg1.jpg)
HAL Id: hal-02383654
https://inria.hal.science/hal-02383654
Submitted on 15 Sep 2021
HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entic research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.
L’archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diusion de documents
scientiques de niveau recherche, publiés ou non,
émanant des établissements d’enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.
Distributed under a Creative Commons Attribution - NonCommercial 4.0 International License
Modern C
Jens Gustedt
To cite this version:
Jens Gustedt. Modern C. Manning, 2019, 9781617295812. �hal-02383654�
![](https://csdnimg.cn/release/download_crawler_static/89449848/bg2.jpg)
Modern C
Jens Gustedt
INRIA, FRANCE
ICUBE, STRASBOURG, FRANCE
This is the 2
nd
edition (minor rev. 2) of this book, as of Oct. 10, 2019.
The free version, sample code, links to Manning’s print edition and much more is available at
https://modernc.gforge.inria.fr/
Special thanks go to the people that encouraged the writing of this book by providing me with constructive
feedback, including
colleagues and other interested readers, Cédric Bastoul, Lucas Nussbaum, Vincent Loechner, Kliment Yanev,
Szabolcs Nagy, Marcin Kowalczuk, Ali Asad Lotia, Richard Palme, Yann Barsamian, Fernando Oleo,
Róbert Kohányi, Jean-Michel Gorius ...
Manning’s staff Jennifer Stout, Nitin Gode and Tiffany Taylor, ...
... and the impressive number of reviewers provided by Manning: Adam Kalisz, Andrei de Araujo Formiga,
Christoph Schubert, Erick Nogueira do Nascimento, Ewelina Sowka, Glen Sirakavit, Hugo Durana,
Jean-François Morin, Kent R. Spillner, Louis Aloia, Manu Raghavan Sareena, Nitin Gode, Rafael Aiquel,
Sanchir Kartiev, and Xavier Barthel
Many others have contributed to the success of this book, my sincerest thanks to all of you.
©2016-2019 Jens Gustedt, Strasbourg, France.
This work is licensed under a Creative Commons “Attribution-NonCommercial-
NoDerivatives 4.0 International” license.
![](https://csdnimg.cn/release/download_crawler_static/89449848/bg3.jpg)
About this book
The C programming language has been around since the early seventies (see Ritchie
[1993]). Since then, C has been used in an incredible number of applications. Programs
and systems written in C are all around us: in personal computers, phones, cameras, set-top
boxes, refrigerators, cars, mainframes, satellites ... basically in any modern device that has
a programmable interface.
In contrast to the ubiquitous presence of C programs and systems, good knowledge
of and about C is much more scarce. Even experienced C programmers often appear to
be stuck in some degree of self-inflicted ignorance about the modern evolution of the C
language. A likely reason for this is that C is seen as an "easy to learn" language, allowing
a programmer with little experience to quickly write or copy snippets of code that at least
appear to do what it’s supposed to. In a way, C fails to motivate its users to climb to higher
levels of knowledge.
This book is intended to change that general attitude, so it is organized in levels that
reflect familiarity with the C language and programming in general. This structure may
go against some habits of the book’s readers; in particular, it splits some difficult subjects
(such as pointers) across levels in order to not swamp readers too early with the wrong
information. We’ll explain the book’s organization in more detail shortly.
Generally, although many universally applicable ideas will be presented, that would
also be valid for other programming languages (such as Java, Python, Ruby, C# or C++)
the book primarily addresses concepts and practices that are unique to C or are of particular
value when programming in the C language.
C versions. As the title of this book suggests, today’s C is not the same language as
the one originally designed by its creator. Right from the start, C has been in a contin-
uous process of adjustment and improvement. Usually, early C is referred to as K&R C
(Kernighan and Ritchie C) after the first book that made the language popular Kernighan
and Ritchie [1978]. Since then, it has undergone an important standardization and exten-
sion process, now driven by ISO, the International Standards Organization. This led to the
publication of a series of C standards in 1989, 1999, 2011, and 2018, commonly referred to
as C89, C99, C11, and C17. The C standards committee puts a lot of effort into guarantee-
ing backward compatibility such that code written for earlier versions of the language, say
C89, should compile to a semantically equivalent executable with a compiler that imple-
ments a newer version. Unfortunately, this backward compatibility has had the unwanted
side effect of not motivating projects that could benefit greatly from the new features to
update their code base.
In this book, we will mainly refer to C17, as defined in JTC1/SC22/WG14 [2018],
but at the time of this writing some compilers don’t implement this standard completely.
If you want to compile the examples in this book, you will need at least a compiler that
implements most of C99. For the changes that C11 added to C99, using an emulation
layer such as my macro package P99 might suffice; the package is available at http:
//p99.gforge.inria.fr.
![](https://csdnimg.cn/release/download_crawler_static/89449848/bg4.jpg)
ii
C and C++. Programming has become a very important cultural and economic ac-
tivity, and C remains an important element in the programming world. As in all human
activities, progress in C is driven by many factors: corporate or individual interest, pol-
itics, beauty, logic, luck, ignorance, selfishness, ego, sectarianism, ... (add your primary
motivation here). Thus the development of C has not been and cannot be ideal. It has flaws
and artifacts that can only be understood with their historical and societal context.
An important part of the context in which C developed was the early appearance of its
sister language, C++. One common misconception is that C++ evolved from C by adding
its particular features. Although this is historically correct (C++ evolved from a very early
C), it is not particularly relevant today. In fact, C and C++ separated from a common
ancestor more than 30 years ago and have evolved separately ever since. But this evolution
of the two languages has not taken place in isolation; they have exchanged and adopted
each other’s concepts over the years. Some new features, such as the recent addition of
atomics and threads, have been designed in close collaboration between the C and C++
standard committees.
Nevertheless, many differences remain, and generally all that is said in this book is
about C, not C++. Many code examples that are given will not even compile with a C++
compiler. So we should not mix sources of both languages.
Takeaway A
C and C++ are different: don’t mix them, and don’t mix them up.
Note that when you are working through this book, you will encounter many lines
marked like that one. These are takeaways that summarize features, rules, recommenda-
tions, and so on. There is a list of these takeaways toward the end of the book, which you
might use as a cheat sheet.
Requirements. To be able to profit from this book, you need to fulfill some minimal
requirements. If you are uncertain about any of these, please obtain or learn them first;
otherwise, you might waste a lot of time.
First, you can’t learn a programming language without practicing it, so you must have
a decent programming environment at your disposal (usually on a PC or laptop), and you
must master it to some extent. This environment can be integrated (an IDE) or a collection
of separate utilities. Platforms vary widely in what they offer, so it is difficult to advise
on specifics. On Unix-like environments such as Linux and Apple’s macOS, you will find
editors such as emacs and vim, and compilers such as c99, gcc, and clang.
You must be able to do the following:
(1) Navigate your file system. File systems on computers are usually organized hier-
archically in directories. You must be able to navigate through these to find and
manipulate files.
(2) Edit programming text. This is different from editing a letter in a word pro-
cessing environment. Your environment, editor, or whatever it is called should
have a basic understanding of the programming language C. You will see that if
you open a C file (which usually has the file extension .c). It might highlight
some keywords or help you indent your code according to the nestedness of {}
brackets.
(3) Execute a program. The programs you will see here are very basic at first and will
not offer you any graphical features. They need to be launched in the command
line. An example of such a program that is launched that way is the compiler.
On Unix-like environments, the command line is usually called a shell and is
launched in a (or the) console or terminal.
(4) Compile programming text. Some environments provide a menu button or a key-
board shortcut for compilation. An alternative to that is to launch the compiler in
the command line of a terminal. This compiler must adhere to recent standards;
don’t waste your time with a compiler that does not conform.
![](https://csdnimg.cn/release/download_crawler_static/89449848/bg5.jpg)
ABOUT THIS BOOK iii
If you have never programmed before, this book will be tough. Knowing some of
the following will help: Basic, C (historical versions), C++, Fortran, R, bash, JavaScript,
Java, MATLAB, Perl, Python, Scilab, and so on. But perhaps you have had some other
programming experience, maybe even without noticing. Many technical specifications
actually come in some sort of specialized language that can be helpful as an analogy: for
example, HTML for web pages and LaTeX for document formatting.
You should have an idea of the following concepts, although their precise meanings
may be a bit different in C than in the context where you learned them:
(1) Variables — Named entities that hold values
(2) Conditionals — Doing something (or not) subject to a precise condition
(3) Iteration — Doing something repeatedly for a specified number of times or until
a certain condition is met
Source code. Many of the programming code snippets that are presented in this book
are available for download as a .zip archive from the book’s website at https://gforge.
inria.fr/frs/download.php/latestfile/5298/code.zip. This allows you to view
them in context and to compile them and try them out. The archive also contains a
Makefile with a description of the components that are needed to compile these files.
It is centered around Linux or, more generally, POSIX systems, but it may also help you to
find out what you need when you are on a different system.
Exercises and challenges. Throughout this book, you’ll see exercises that are meant
to get you thinking about the concepts being discussed. These are probably best done
directly along with your reading. Then there is another category called “challenges.” These
are generally more demanding. You will need to do some research to even understand what
they are about, and the solutions will not come all by themselves: they will require effort.
They will take more time, sometimes hours or, depending on your degree of satisfaction
with your work, even days. The subjects covered in these challenges are the fruit of my
own personal bias toward “interesting questions” from my personal experience. If you
have other problems or projects in your studies or your work that cover the same ground,
they should do equally well. The important aspect is to train yourself by first searching for
help and ideas elsewhere, and then to get your hands dirty and get things done. You will
only learn to swim if you jump into the water.
Organization. This book is organized in levels, numbered from 0 to 3. The starting
level 0, named "Encounter," will summarize the very basics of programming with C. Its
principal role is to remind you of the main concepts we have mentioned and familiarize
you with the special vocabulary and viewpoints that C applies.
1
By the end of it, even if
you don’t have much experience in programming with C, you should be able to understand
the structure of simple C programs and start writing your own.
The "Acquaintance" level 1 details most principal concepts and features such as con-
trol structures, data types, operators, and functions. It should give you a deeper under-
standing of the things that are going on when you run your programs. This knowledge
should be sufficient for an introductory course in algorithms and other work at that level,
with the notable caveat that pointers are not yet fully introduced.
The "Cognition" level 2 goes to the heart of the C language. It fully explains point-
ers, familiarizes you with C’s memory model, and allows you to understand most of C’s
library interface. Completing this level should enable you to write C code professionally;
it therefore begins with an essential discussion about the writing and organization of C
programs. I personally would expect anybody who graduated from an engineering school
with a major related to computer science or programming in C to master this level. Don’t
be satisfied with less.
1
One of C’s special viewpoints is that indexing starts at 0, and not at 1 as in Fortran.
剩余324页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
concisedistinct
- 粉丝: 1001
- 资源: 110
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- elasticsearch数据库下载、配置、使用案例
- springboot的概要介绍与分析
- C语言的概要介绍与分析
- 第一个较大的Android项目,基于Android平台的图书管理系统(Android studio).zip
- Cisco Packet Tracer 6.2 for Windows Instructor Version
- 使⽤pyIAST计算⽓体吸附选择性
- tmp_b056727e59b8123365486983f32baa9732607ec3c6137b12.pdf
- C代码实现文件的拆分和合并,本质上就是文件的读写操作.zip
- TVMP3player.apk.1
- 出马出马出马出马出马出马出马
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)