Programming-Idioms

History of Idiom 162 > diff from v9 to v10

Edit summary for version 10 :
New C implementation by user [phrank]

Version 9

2018-06-12, 09:46:03

Version 10

2019-09-26, 15:55:27

Idiom #162 Execute procedures depending on options

execute bat if b is a program option and fox if f is a program option.

Idiom #162 Execute procedures depending on options

execute bat if b is a program option and fox if f is a program option.

Imports
#include <unistd.h>
Code
int main(int argc, char * argv[])
{
        int optch;
        while ((optch = getopt(argc, argv, "bf")) != -1) {
                switch (optch) {
                        case 'b': bat(); break;
                        case 'f': fox(); break;
                }
        }
        return 0;
}
Doc URL
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html