r/backtickbot • u/backtickbot • Jul 09 '21
https://np.reddit.com/r/voidlinux/comments/ogb5wo/void_linux_inspired_me_to_do_something/h4lc7cx/
For the first try on C this is quite good.
I'd like to add some recommendations:
instead of
if ( argc < 2 || argc > 3) { //If this OR that
help();
}
go with this
// check argument count and maybe print help
if ( argc != 2 ) {
help(argc);
exit(1);
} else {
/* program code */
exit(0);
}
of course you can move the exit code to the help function.
Also I'd encourage you either switch the number of arguments in the help function or use different names. (enable is a better name if the function in enabling something. It could be usage_enable() for the enable keyword.)
It is a good effort though and you chose something interesting for your first project. Keep on it.
1
Upvotes