liveBook · Manning

Chapter 14: More involved processing and I/O

What you will learn in chapter 14 of Modern C, Third Edition

The introduction connects the chapter’s text-processing and formatted-input topics to the pointer concepts covered earlier.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction connects the chapter’s text-processing and formatted-input topics to the pointer concepts covered earlier.

Key terms: pointers, text processing, formatted input

14.1 Text processing

The section uses a line-of-numbers program to explain string conversion, line reading, const safety, and safe formatting into character buffers.

Key terms: numberline_inner, strtoull, next, base, numberline, np, memchr, malloc, realloc, const-safe

14.2 Formatted input

This section introduces the scanf family for formatted input and explains conventions that make it easy to read more input than intended.

Key terms: fscanf, scanf, sscanf, stdin, pointers, white space, scanf family, %c, %s, char*

14.3 Extended character sets

This section explains how C programs can use extended characters through locales, multibyte strings, Unicode code points, and conversion to wide characters.

Key terms: setlocale, native locale, extended characters, multibyte character, multibyte string, null terminated, strlen, mbsrlen, Unicode, code point

14.4 UTF character encodings

The section explains C’s direct support for UTF encodings, why UTF-16 needs special care, and where standard-library and compiler support may vary.

Key terms: multibyte encoding, UTF-8, UTF-16, UTF-32, u8, u, char8_t, char16_t, char32_t, surrogate pairs

14.5 Restartable text conversion

This section explains how restartable conversion functions preserve state across incomplete multibyte input and illustrates their use in a UTF-8 scanning example.

Key terms: restartable, state parameter, mbstate_t, multibyte mb encoding, mbincomplete, mbstored, mb encoding, setlocale, mbrtoc8, input buffer ib

14.6 Binary streams

Explains why binary streams are needed for byte-preserving I/O, how to read and position within them, their portability limits, and how C23 can embed binary files in source code.

Key terms: text mode, binary mode, fread, fwrite, ftell, fseek, file position, SEEK_SET, internal representations, endian-ness

14.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 13: Storage Chapter 15: Program failure →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.