Skip to the content.

Chapter 5: Pointers and Arrays

Exercises from “The C Programming Language” (2nd Edition) by Brian W. Kernighan and Dennis M. Ritchie.

Exercises

# Description Source
5-01 getint with + or - not followed by digit -
5-02 getfloat: floating-point analog of getint -
5-03 strcat using pointers -
5-04 strend(s, t): check if t occurs at end of s -
5-05 strncpy, strncat, strncmp -
5-06 Rewrite functions using pointers -
5-07 Rewrite readlines with fixed array -
5-08 Error checking for day_of_year and month_day -
5-09 Rewrite day/month using pointers -
5-10 expr: evaluate RPN from command line -
5-11 Detab/entab with tab stop arguments -
5-12 Detab/entab with -m +n arguments -
5-13 tail -n: print last n lines -
5-14 Sort with -r (reverse) flag -
5-15 Sort with -f (fold case) flag -
5-16 Sort with -d (directory order) flag -
5-17 Sort with field handling -
5-18 Recover from input errors in dcl -
5-19 undcl: convert words to declaration -
5-20 Expand dcl for qualifiers -

Compilation

gcc -Wall -Wextra -o exercise exercise.c
./exercise