contents

front matter

preface

acknowledgments

about this book

about the author

about the cover illustration

1 Configuration and setup

1.1 The C development cycle

Editing source code

Compiling, linking, building

1.2 The integrated development environment (IDE)

Choosing an IDE

Using Code::Blocks

Using XCode

1.3 Command-line compiling

Accessing the terminal window

Reviewing basic shell commands

Exploring text screen editors

Using a GUI editor

Compiling and running

1.4 Libraries and compiler options

Linking libraries and setting other options in an IDE

Using command-line compiler options

1.5 Quiz

2 Daily greetings

2.1 The shell starts

Understanding how the shell fits in

Exploring various shell startup scripts

Editing the shell startup script

2.2 A simple greeting

Coding a greeting

Adding a name as an argument

2.3 The time of day

Obtaining the current time

Mixing in the general time of day

Adding specific time info

2.4 The current moon phase

Observing moon phases

Writing the moon phase algorithm

Adding the moon phase to your greeting

2.5 A pithy saying

Creating a pithy phrase repository

Randomly reading a pithy phrase

Adding the phrase to your greeting code

3 NATO output

3.1 The NATO alphabet

3.2 The NATO translator program

Writing the NATO translator

Reading and converting a file

3.3 From NATO to English

Converting NATO input to character output

Reading NATO input from a file

4 Caesarean cipher

4.1 I/O filters

Understanding stream I/O

Writing a simple filter

Working a filter at the command prompt

4.2 On the front lines with Caesar

Rotating 13 characters

Devising a more Caesarean cipher

4.3 Deep into filter madness

Building the hex output filter

Creating a NATO filter

Filtering words

5 Encoding and decoding

5.1 The concept of plain text

Understanding ASCII

Exploring the control codes

Generating noncharacter output

Playing with ASCII conversion tricks

5.2 The hex encoder/decoder

Writing a simple hex encoder/decoder

Coding a better hex encoder/decoder

Adding a wee bit of error-checking

5.3 URL encoding

Knowing all the URL encoding rules

Writing a URL encoder

Creating a URL decoder

6 Password generators

6.1 Password strategies

Avoiding basic and useless passwords

Adding password complexity

Applying the word strategy

6.2 The complex password jumble

Building a silly random password program

Adding conditions to the password program

Improving upon the password

6.3 Words in passwords

Generating random words, Mad Libs style

Building a random word password generator

7 String utilities

7.1 Strings in C

Understanding the string

Measuring a string

Reviewing C string functions

Returning versus modifying directly

7.2 String functions galore

Changing case

Reversing a string

Trimming a string

Splitting a string

Inserting one string into another

Counting words in a string

Converting tabs to spaces

7.3 A string library

Writing the library source and header file

Creating a library

Using the string library

7.4 A kinda OOP approach

Adding a function to a structure

Creating a string “object”

8 Unicode and wide characters

8.1 Text representation in computers

Reviewing early text formats

Evolving into ASCII text and code pages

Diving into Unicode

8.2 Wide character programming

Setting the locale

Exploring character types

Generating wide character output

Receiving wide character input

Working with wide characters in files

9 Hex dumper

9.1 Bytes and data

Reviewing storage units and size mayhem

Outputting byte values

Dumping data

9.2 Dump that file!

Reading file data

Fixing uneven output

9.3 Command-line options

Using the getopt() function

Updating the dumpfile program code

Setting abbreviated output

Activating octal output

10 Directory tree

10.1 The filesystem

10.2 File and directory details

Gathering file info

Exploring file type and permissions

Reading a directory

10.3 Subdirectory exploration

Using directory exploration tools

Diving into a subdirectory

Mining deeper with recursion

10.4 A directory tree

Pulling out the directory name

Monitoring directory depth

11 File finder

11.1 The great file hunt

11.2 A file finder

Coding the Find File utility

Understanding the glob

Using wildcards to find files

11.3 The duplicate file finder

Building a file list

Locating the duplicates

12 Holiday detector

12.1 The operating system wants its vig

Understanding exit status versus the termination status

Setting a return value

Interpreting the return value

Using the preset return values

12.2 All about today

Getting today’s date

Obtaining any old date

12.3 Happy holidays

Reviewing holidays in the United States

Discovering holidays in the UK

12.4 Is today a holiday?

Reporting regular date holidays

Dealing with irregular holidays

Calculating Easter

Running the date gauntlet

13 Calendar

13.1 The calendar program

13.2 Good dates to know

Creating constants and enumerating dates

Finding the day of the week

Calculating the first day of the month

Identifying leap years

Getting the time zone correct

13.3 Calendar utilities

Generating a week

Showing a month

Displaying a full year

Putting the full year into a grid

13.4 A calendar in color

Understanding terminal colors

Generating a tight-but-colorful calendar

Coloring holidays

14 Lotto picks

14.1 A tax for those who are bad at math

Playing the lottery

Understanding the odds

Programming the odds

14.2 Here are your winning numbers

Generating random values

Drawing lotto balls

Avoiding repeated numbers, another approach

14.3 Never tell me the odds

Creating the lotto() function

Matching lottery picks

Testing the odds

15 Tic-tac-toe

15.1 A silly kids’ game

Playing tic-tac-toe

Approaching the game mathematically

15.2 The basic game

Creating the game grid

Adding game play

Limiting the input to free squares

Determining the winner

15.3 The computer plays

Choosing the number of players

Coding a dumb opponent

Adding some intelligence

index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset