### Enable Global File-Name Expansion

You can receive arguments that the user types on the command line as arguments to the main function of your program. To allow the global file-name characters ? and * in file-name and path-name arguments at the command prompt, you must link your program with the special routine contained in setargv.obj. This object file is included with the libraries in the LIB directory under the main IBM C and C++ Compilers directory.

The code in setargv.obj expands global file-name characters in the same manner as the command line interpreter of your operating system. The expanded list of file names is sorted in lexical order. If the setargv function finds no matches for the global file-name arguments, or if the wildcard characters are enclosed in quotation marks, the argument is passed literally.

If your program does not link with setargv.obj, the wildcard characters are taken literally.

Use the source configuration file directive to indicate that setargv.obj is an input file to the build. For example the following excerpt from a configuration file builds the executable testing.exe from a single c source and header file:

    source testsrc = "testing.c", "testing.h"
    target "testing.exe" {
       option /NOEXTDICTIONARY
       source testsrc, "setargv.obj"
    }

To run the program made with this example, and pass as arguments all file names in the current directory with the extension INC and all file names beginning with ABC followed by any one character, enter the following command:

>      testing *.INC ABC?

If you frequently use global file-name expansion, you can place the setargv.obj routine in the standard libraries you use by replacing the module named setuparg with the setargv.obj module. These module names are the same in all IBM C and C++ Compilers libraries. Use the ILIB utility to delete setuparg and add setargv.obj. In programs built with the resulting library, global file-name expansions are performed automatically on command-line arguments.

Run Your Application
Receive Data as Arguments of main