Mikael Olsson
Modern C Quick Syntax Reference A Pocket Guide to the Language, APIs, and Library 2nd ed.
Mikael Olsson
Hammarland, Lnsi-Suomi, Finland
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484242872 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-4287-2 e-ISBN 978-1-4842-4288-9
https://doi.org/10.1007/978-1-4842-4288-9
Library of Congress Control Number: 2018967003
Mikael Olsson 2019
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.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, 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.
Introduction
The C programming language is a general-purpose, middle-level language originally developed by Dennis M. Ritchie at Bell Labs. It was created over the period 1969 through 1973 for the development of the UNIX operating system, which had previously been written in assembly language. The name C was chosen because many of its features derived from an earlier language called B. Whereas the B language is no longer in common use, C became and still remains one of the most popular and influential programming languages in use today.
Although C is a general-purpose language, it is most often used for systems programming. This includes software that controls the computer hardware directly, such as drivers, operating systems, and software for embedded microprocessors. C can also be used for writing applications, which run on top of system software. However, it has largely been superseded in that domain by higher-level languages, such as C++, Objective-C, C#, and Java. The features of these and many other languages are heavily influenced by C, as can be seen in some of their names.
The development of C was a major milestone in computer science, as it was the first widely successful middle-level language for system development. The foremost reasons for its success were that the language was concise, fast, and powerful. It offered comparable speed to assembly with far improved usability. The high-level constructs of the language allowed programmers to focus mainly on the softwares design, while its low-level capabilities still provided direct access to the hardware when needed, as assembly had done. Furthermore, the language is relatively simple to understand, with few keywords and what many consider to be an elegant syntax.
Another major reason for the success of C was its portability. Unlike assembly, the C language is platform independent. A standards-compliant C program can therefore be compiled for a wide variety of computer systems with few changes to its source code. Moreover, the C compiler was small and easy to port to different CPU architectures, which together with the languages popularity has made C compilers available on most computer systems.
C Versions
In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as K&R C. This description was succeeded in 1989 when the American National Standards Institute (ANSI) provided a comprehensive definition of C known as ANSI C or C89. In the following year, the same specification was adopted as an international standard by the International Organization for Standardization and became known as ISO C90 or just C90. C has since undergone four more revisions by ISO (successively adopted by ANSI) with further language extensions, including C95, C99, C11, and most recently C18, which is the latest ANSI standard for the C programming language. The current C18 standard provided only clarifications to C11 and introduced no new language features.
Table of Contents
About the Author and About the Technical Reviewer
About the Author
Mikael Olsson
is a professional web entrepreneur, programmer, and author. He works for an R&D company in Finland where he specializes in software development. In his spare time, he writes books and creates websites that summarize various fields of interest. The books he writes are focused on teaching their subject in the most efficient way possible, by explaining only what is relevant and practical without any unnecessary repetition or theory. The portal to his online businesses and other websites is Siforia.com .
About the Technical Reviewer
Michael Thomas
has worked in software development for more than 20 years as an individual contributor, team lead, program manager, and vice president of engineering. Michael has more than 10 years of experience working with mobile devices. His current focus is in the medical sector, using mobile devices to accelerate information transfer between patients and health care providers.
Mikael Olsson 2019
Mikael Olsson Modern C Quick Syntax Reference https://doi.org/10.1007/978-1-4842-4288-9_1
1. Hello World
Mikael Olsson
(1)
Hammarland, Lnsi-Suomi, Finland
To begin programming in C, you need a text editor and a C compiler. You can get both at the same time by installing an Integrated Development Environment (IDE) that includes support for C. A good choice is Microsofts Visual Studio Community Edition, which is a free version of Visual Studio available from Microsofts website. This IDE has built-in support for the C89 standard and includes most features up to C99 as of the 2017 version.