Skip to content

Instantly share code, notes, and snippets.

@lelanthran
lelanthran / process_args_test.c
Last active August 31, 2019 22:30
More comprehensive c/line arguments processing
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
/* ********************************************************************
* An even more comprehensive command-line parsing mechanism. This method
* allows the program to have long options (--name=value) short options
* (-n value or -nvalue or -abcnvalue) mixed with non-options (arguments
* without a '-' or '--'.
@lelanthran
lelanthran / cline_test.c
Last active May 27, 2019 21:15
Single function to get command-line options in both long and short form.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
/* *****************************************************************
* A more robust command-line handling function than I normally use.
* There are only two functions, so this is suitable for copying and
* pasting into the file containing main().