c - Adding a help switch to a console application -


i know how make applications run in terminal. mean program can type -h @ time , have different choices of commands run... i.e. linux application run out of terminal.

any resources appreciated.

in c, main routine written as:

int main(int argc, char *argv[]) 

that argv array arguments (argv[0] name of command ran), check if(argc > 1 && !strcmp(argv[1], "-h")) see if running -h (and use printf print terminal).

if want more proper argument parsing library, @ getopt (https://www.gnu.org/software/libc/manual/html_node/example-of-getopt.html). gnu version (which 1 linux distros use) has features long arguments (handling -h , --help)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -