Book Image

C++ System Programming Cookbook

By : Onorato Vaticone
Book Image

C++ System Programming Cookbook

By: Onorato Vaticone

Overview of this book

C++ is the preferred language for system programming due to its efficient low-level computation, data abstraction, and object-oriented features. System programming is about designing and writing computer programs that interact closely with the underlying operating system and allow computer hardware to interface with the programmer and the user. The C++ System Programming Cookbook will serve as a reference for developers who want to have ready-to-use solutions for the essential aspects of system programming using the latest C++ standards wherever possible. This C++ book starts out by giving you an overview of system programming and refreshing your C++ knowledge. Moving ahead, you will learn how to deal with threads and processes, before going on to discover recipes for how to manage memory. The concluding chapters will then help you understand how processes communicate and how to interact with the console (console I/O). Finally, you will learn how to deal with time interfaces, signals, and CPU scheduling. By the end of the book, you will become adept at developing robust systems applications using C++.
Table of Contents (13 chapters)

Working with files

This recipe will teach you the fundamental knowledge needed to deal with files. The C++ Standard Library historically offers a very good interface, but C++ 17 added a namespace called std::filesystem, which further enriches the offer. We'll not take advantage of the C++17 std::filesystem namespace, though, as it was already introduced in Chapter 2, Revisiting C++. Think about a concrete use case of creating a configuration file, or where you'd need to make a copy of that configuration file. This recipe will teach you how C++ makes this task easy.

How to do it...

In this section, we'll write three programs to learn how to work with files by using std::fstreamstd::ofstream,...