This repository contains my solutions to exercises presented in the C Primer Plus, 6th edition by Stephen Prata. All solutions was compiled and tested on macOS High Sierra (ver.10.13.6), Xcode 10.1, using the clang compiler Apple LLVM version 10.0.0 (clang-1000.11.45.5).
- 03. Data and C
- 04. Character Strings and Formatted Input/Output
- 05. Operators, Expressions, and Statements
- 06. C Control Statements: Looping
- 07. C Control Statements: Branching and Jumps
- 08. Character Input/Output and Input Validation
- 09. Functions
- 10. Arrays and Pointers
- 11. Character Strings and String Functions
- 12. Storage Classes, Linkage, and Memory Management
- 13. File Input/Output
- 14. Structures and Other Data Forms
- 15. Bit Fiddling
- 16. The C Preprocessor and the C Library
- 17. Advanced Data Representation
Extras Folder contains my test programs or experiments:
- filecopy.c: implementation of the ex11_02 with
getc()
andputc()
functions. - persons.c: a warm-up program before doing ex14_07.
- printer.c: prints contents of the text file, but replaces each invisible
\n
character with the visible\n
output. - revstr.c: the
revstr()
function (ex11_09) with a temporary VLA array. - spacer.c: inserts whitespace characters between the characters of the text file.
Data Folder contains text and data files.
Files with .dat
extension are the parts of some exercises and contain the data for the program execution.
Text files are provided to support manually testing the exercises.
- /flights: the folder contains data files for the ex14_09 execution. Each file has the data of the Colossus Airlines flight with the corresponding flight number.
- alice_in_wonderland.txt: project Gutenberg's "Alice's Adventures in Wonderland", by Lewis Carroll
- alphabet.txt: 26 lines with the alphabetic characters.
- book.dat: the books database for ex14_07.
- digits.spaced.txt: input file for ex13_12, ex13_13, and ex13_14. The file was created by applying
spacer.c
ondigits.txt
. - digits.txt: 20x30 digits file with no spaces.
- fewlines.txt: few lines of the text.
- flight.dat: the database for the first Colossus Airlines flight (ex14_08).
- movies.txt: 11 "movies" to input for ex17_01 - ex17_03
- persons.dat: is used by
persons.c
(feed the address to the file as a command-line argument). - softball.txt: the softball team statistics, for use with the ex14_06.
- words.txt: the text file on which I tested ex17_07.
These solutions are copyright under the terms of the MIT LICENSE (see LICENSE) with the following exception:
- The source code of this project is directly the answers for the exercises presented in the book "C Primer Plus, 6th edition" by Stephen Prata (2014). The text of most of the opening comments of the solutions, which contain the exercise conditions, can partially or completely recite the corresponding fragments of the book with the original exercise conditions. Therefore, before-mentioned fragments of comments fall under the influence of the publisher's copyright.