To set up your program to receive data from the command line, declare arguments to your function main, as in the following definitions:
IBM C and C++ Compilers allows a return type of void for main.
Use argc and argv to extract arguments supplied to your program by the user. The integer argc holds the number of parameters supplied to the program. The program name is always the first command line argument and is stored in argv[0]. Run-time initialization code stores all arguments supplied on the command line after the program name, as null-terminated strings, in argv[1] , argv[2] , and so on.
To let users specify the wildcard characters ? and * in file-name and path-name arguments, enable your program for global file-name expansion.
The third argument passed to main is envp. It is a pointer to the environment table, and is not available when you use the subsystem libraries. To access the value of the environment settings, you can use the envp pointer, but it is easier to call the getenv function. The putenv function may change the location of the environment table in storage, depending on storage requirements. As a result, the value given to envp when you start to run your program might not be correct throughout the running of the program. The putenv and getenv functions access the environment table correctly, even when its location changes.
![]()
Run Your Application
Enable Global
File-Name Expansion