Explore 1.5M+ audiobooks & ebooks free for days

Only $12.99 CAD/month after trial. Cancel anytime.

C Programming Pocket Primer: An Essential Guide to C Programming Basics
C Programming Pocket Primer: An Essential Guide to C Programming Basics
C Programming Pocket Primer: An Essential Guide to C Programming Basics
Ebook411 pages3 hours

C Programming Pocket Primer: An Essential Guide to C Programming Basics

Rating: 0 out of 5 stars

()

Read preview
LanguageEnglish
PublisherPackt Publishing
Release dateJul 26, 2024
ISBN9781836644460
C Programming Pocket Primer: An Essential Guide to C Programming Basics
Author

Mercury Learning and Information

MERCURY LEARNING and INFORMATION publishes content in the areas of science and medicine, technology and computing, engineering, and mathematics designed for the professional/reference, trade, library, higher education, career school, and online training markets.

Read more from Mercury Learning And Information

Related to C Programming Pocket Primer

Related ebooks

Programming For You

View More

Reviews for C Programming Pocket Primer

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    C Programming Pocket Primer - Mercury Learning and Information

    PREFACE

    WHAT IS THE GOAL?

    The goal of this book is to introduce advanced beginners to C programming fundamentals. Hence, the material is primarily for people who have some programming experience, and not really suitable for absolute beginners. This book is suitable as a fast-paced introduction to various core features of C. The purpose of the material in the chapters is to illustrate how to solve a variety of tasks using C, after which you can do further reading to deepen your knowledge.

    There is one other point to remember as you read this book: this book will not make you an expert programmer in C.

    IS THIS BOOK IS FOR ME AND WHAT WILL I LEARN?

    This book is intended for beginner to intermediate programmers with a year or two of experience in another language who wish to learn C. You need some familiarity with working from the command line in a Unix-like environment. However, there are subjective prerequisites, such as a strong desire to learn how to write C programs, along with the motivation and discipline to read and understand the code samples.

    If you are adequately prepared and motivated, you will learn how to write C programs that involve various C data types, loops, conditional logic, built-in functions, custom functions, and recursion.

    This book saves you the time required to search for relevant code samples, adapting them to your specific needs, which is a potentially time-consuming process. In any case, if you’re not sure whether or not you can absorb the material in this book, glance through the code samples to get a feel for the level of complexity.

    WHAT ARE THE STRENGTHS OF THIS BOOK?

    The top three strengths of this book can be summarized as follows:

    This is a modern textbook with up-to-date information regarding the C11 standard

    There are detailed explanations of the code samples because nothing is assumed, which means that beginners can work through the examples side-by-side with the explanation

    No assumptions regarding the level of programming skills of the readers

    One other point to keep in mind: as you might have noticed, many introductory books are written assuming a computer science background: this book arguably is readable without that theoretical foundation.

    WHAT ARE THE WEAKNESSES OF THIS BOOK?

    The weaknesses of this book can be summarized as follows:

    A thorough coverage of just the essentials of C in a book this short is difficult. You need to learn many details in order to become a good C programmer; hence, this book serves as a sort of stepping stone in your learning path regarding C.

    The examples are necessarily simplistic, and cannot show the best style in a book for beginners because the best style is too complex to illustrate the simple concepts.

    Some readers might find the introductory level of the material boring and simple. This is not a problem of the book, but the fact that C is so low-level that the foundations appear trivial. (They absolutely are not, but they look that way to a beginner.)

    HOW WERE THE CODE SAMPLES CREATED?

    The code samples in this book were created and tested using bash on a Macbook Pro with OS X 10.12.6 (macOS Sierra). Regarding their content: the code samples are derived primarily from the author, and in some cases there are code samples that incorporate short sections of code from discussions in online forums. The key point to remember is that the overwhelming majority of the code samples follow the Four Cs: they must be Clear, Concise, Complete, and Correct to the extent that it’s possible to do so, given the size of this book.

    WHY ARE THERE TWO CHAPTERS ABOUT POINTERS IN C?

    A misunderstanding of pointers is the most common cause of crashes in C programs. Although C pointers can be explained quickly, code samples involving pointers can quickly become difficult to understand (and also error-prone). This is a difficult subject (even for advanced beginners) if you are unfamiliar with this functionality. Hence, one chapter about C pointers simply isn’t enough to become comfortable with this topic.

    As you will see, Chapter 5 contains basic code samples involving pointers, which are enough for simple C programs. If you want a deeper understanding of how to use pointer, read the code samples in Chapter 6, and experiment with your own variations of the code. If you want to become adept in a programming language, you need to actively practice writing code, which is especially true for C programs that involve pointers.

    WHICH TOPICS ARE EXCLUDED?

    This book does not cover hashing, searching and sorting, file I/O, data structures, threads, sockets, IPC, pipes, shared memory, message queues, and other system-level functionality that are relevant for advanced and expert-level developers. These topics are excluded because they are not suitable for an introductory C book, and there are plenty of other concepts that you need to learn in order to write C programs. Note that Chapter 7 briefly covers bit manipulation and more sophisticated C operators that you will need to learn if you become a full-time C developer.

    HOW DO I SET UP A COMMAND SHELL?

    If you are a Mac user, there are three ways to do so. The first method is to use Finder to navigate to Applications > Utilities and then double click on the Utilities application. Next, if you already have a command shell available, you can launch a new command shell by typing the following command:

    open /Applications/Utilities/Terminal.app

    A second method for Mac users is to open a new command shell on a Macbook from a command shell that is already visible simply by clicking command+n in that command shell, and your Mac will launch another command shell.

    If you are a PC user, you can install Cygwin (open source https://cygwin.com/) that simulates bash commands, or use another toolkit such as MKS (a commercial product). Please read the online documentation that describes the download and installation process. Note that custom aliases are not automatically set if they are defined in a file other than the main start-up file (such as .bash_login).

    WHAT ARE THE NEXT STEPS AFTER FINISHING THIS BOOK?

    The answer to this question varies widely, mainly because the answer depends heavily on your objectives. The best answer is to try a new tool or technique from the book on a problem or task you care about, professionally or personally. Precisely what that might be depends on who you are, as the needs of a data scientist, manager, student or developer are all different. In addition, keep what you learned in mind as you tackle new data cleaning or manipulation challenges. Sometimes knowing a technique is possible makes finding a solution easier, even if you have to re-read the section to remember exactly how the syntax works.

    If you have reached the limits of what you have learned here and want to get further technical depth about regarding C, there are various online resources and literature describing more complex features of C.

    Oswald Campesato

    January 2019

    ABOUT THE TECHNICAL EDITOR

    Ansel Sermersheim has been working as a computer developer for nearly twenty years programming in C, C++, Lisp, Java, and Perl, with extensive knowledge in TCP/IP and multithreaded design. He has been a speaker at CppCon 2015, CppNow 2016, CppNow 2017, CppCon 2017, CppCon 2018, and numerous San Francisco Bay Area meetings of ACCU, the Association of C, and C++

    Enjoying the preview?
    Page 1 of 1