I am writing a program in C which is like a console so that user can specify different commands to be executed(which are also defined by me). Just like the one below:
>cmd1 arg
(result blah blah blah)
>
and I want to display usage info which is like:
>help
Usage: cmd1 arg1 [arg2]
cmd2 arg1 [arg2]
cmd3 arg1 [arg2]
....
But I find it clumsy to define string or macro like "Usage: cmd1 arg1 [arg2] \n \t "... (and I am not sure it’s OK or not).
Is there some best practice to do so?
The standard practice is to make a
usagefunction that you can call when certain conditions are met (there were no arguments pass to the program, etc), like this: