ARGS is a C++ program which demonstrates the retrieval of command line arguments.
This shows how a program can count and retrieve the individual command line arguments with which it was invoked. Thus, if our executable is called fu and we invoke it with the command
fu man chuthen our argument counter will return the value 3, and the arguments, indexed by 0, 1 or 2, will return the values fu, man or chu.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
ARGS is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.
ARGS is a program which reports the command line arguments with which it was invoked.
ARGS_TO_STRINGS shows that the command line arguments can easily be converted to C++ strings.
PRIME_SUM is a program which expects one command line argument, an integer N. It reads N, computes the sum of the prime numbers up to N, and prints it out. The program demonstrates how a command line argument, which is a STRING, can be converted to an INTEGER, using the function atoi.
You can go up one level to the C++ source codes.