w4jbm / C-Programs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C-Programs

Various programs in C.

callsort.c

Demo of calling the Linux sort command from within a C program. Not particularly useful, but could be the starting point for something more elaborate.

colors.c

A simple demo of the use of ANSI escape codes to change colors and attributes of text output to the console.

dump.c

A simple program to create a traditional hex dump of a file.

num_guess.cpp

Nothing fancy, but all the "sample" programs I came across when I was playing around would end up in an endless loop if you entered something other than an integer as your guess.

num2words.c

This takes an integer between 0 and 1,000 and converts it to words. (If you don't provide a number, it gives you 15 examples starting at a random point.)

This is similar to a program I used almost four decades ago to print checks for payroll and accounts payable applications I developed. You have to think through some of the quirks in how we word things.

It actually even gets at some interesting history of our number system if you think about it. We have "works" for the numbers 1 through 12. (Then we have the "teens".) At one point, 12 was an important number (and still figures into things like the number hours in half a day and the number of months in a year). Some fraction also have that property--we have one-half and one-quarter while the rest (like one-third or one-eigth) take "numbers" (in the examples, 3 and 8) and make use of them.

As I recall, I think my verion in BASIC went up to numbers as high as 9,999 which was a fair amount of money at the time. (Anything higher was something the company's owner wanted to know about anyway, so having to manually write the check provided a type of 'checks and balances'.)

nxtafter.c

Some tinkering with one of the more obscure functions you'll likely never use in C...

And the fine print...

To the extent applicable, all code and other material in this repository is:

Copyright 2019-2020 by James McClanahan and made available under the terms of The MIT License.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About


Languages

Language:C 88.2%Language:C++ 11.8%