Say your signal processing program, sigproc.exe, will have 4 arguments/variables:
C variable
cmd switch default if no switch
~~~~~~~~~~
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
char* input_file -i
temp.wav
char* output_file -o
temp.dat
int fft_size
-fft 64
int window_type -wt
1
So, for example, the command line would look like:
sigproc -i fox.wav -o fox.dat -fft 128 -wt 2
And if any of the switches are missing, the default will be used.
~~~ THEREFORE, AN EXAMPLE: ~~~
| int main(int argc, char * argv[])
{ // variable switch default // ^^^^^^^^ ^^^^^^ ^^^^^^^ char* input_file =ArgStr("-i", "temp.wav", argc, argv); char* output_file =ArgStr("-o", "temp.dat", argc, argv); int fft_size =ArgInt("-fft", 64 , argc, argv); int window_type =ArgInt("-wt", 1, argc, argv); // So, after this phase, all the variables should be set
to either
// Be careful with the char* return values. You have to
allocate temp
} |
Easy, NO?