Skip to content

Growing inventory of C language modules that solve my recurring programming needs.

Notifications You must be signed in to change notification settings

cjungmann/c_patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

108 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C Patterns

A collection of diverse module source files with interesting solutions to programming challenges.

Table of Contents

About the Project

This repository exists for me to gather non-trivial programming solutions for future reference.

Download the Project

git clone https://github.com/cjungmann/c_patterns.git

Using the Project

The modules are generally independent. Most include some code that can be copied to another project, though some are incomplete ideas that need work (commaize.c, I'm looking at you).

Compiling

Nearly all of the modules include a Local Variables section with a compile-command that informs Emacs how to generate an executable for demonstration and testing.

Modules that are meant to be directly included into another project have the testing and main function code fenced behind an #ifdef block, which is triggered by the compile-command.

Documentation

Documentation style is an ongoing project for me. I pay attention to what works and doesn't work and try to improve my meager skills at documentation. Newer modules will usually have better documentation, though I may revisit old modules to improve things if they're too bad.

I won't necessarily fix old modules. Be prepared to dig around a bit for useful stuff.

Contents

Going forward, more recent efforts should be at the top in order to prioritize the accumulation of experience in coding, documenting, organizing, etc.

  • Yet-another-itoa
    Called itoa to mirror library function atoi, this source file contains several variations of a function that converts an integer value to a string. It includes some testing code that uses snprintf as a benchmark for speed and output. It also uses [PerfTest][README_perftest.md) to compare the performance of the different versions.

  • Performance Tester
    While considering the value of my new itoa function, it made sense to develop a suite of timing functions to compare the performance different itoa implementations.

  • Line-reading Function
    Collecting data from various sources usually requires processing files by line. The main function, read_file_lines buffers the contents of a file and invokes a callback function to present a line to be processed.

  • commaize
    This function, found in commaize.c, uses recursion to break up a number from the small-end and displays it when the recursion unwinds. I recently found out that you can do the same thing including an apostrophe in the format specifier when using printf when setlocale is used.

  • [Columns display][README_columnize.md) Displays a list of strings in column form, according to the screen dimensions.

  • Make an array of strings
    This module can break a string into an array of strings, which is then made available through a callback function modeled after main() with a void return type.

  • get_keypress
    Functions the provide immediate recognition of individual keypresses, including non-printable keys. Source code in get_keypress.c.

  • Initializing Struct Arrays
    I often iterate over static arrays to perform repetitve tasks like listing program options, simulate user responses, etc. I frequently have trouble initializing these arrays. This guide should help me remember effective coding techniques.

  • isJsonNumber Quickly developed code to support JSON parsing. Follows standards set out by RFC-8259 and passes number parsing tests found in Parsing JSON is a Minefield.

About

Growing inventory of C language modules that solve my recurring programming needs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published