Print the arguments to the program to the standard output - C++ Function

C++ examples for Function:main function

Description

Print the arguments to the program to the standard output

Demo Code

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    cout << "The arguments to " << pszArgs[0] << " are:\n";

    for (int i = 1; i < nNumberofArgs; i++)
    {// w  ww.  j  ava 2s  .c  o m
        cout << i << ":" << pszArgs[i] << "\n";
    }

    cout << "That's it" << endl;

    return 0;
}

Result


Related Tutorials