Command Line Arguments in C++
Whenever you want to pass argument at execution time of code; this is only possible with the help of Command Line Arguments. It is used to give input to a program that you are going to execute.
Here we discuss about Command line arguments in C++
The main function would be the following:
int main (int argc, char *argv[])
Example of Command line arguments in C++
#include<iostream.h>
using namespace std;
int main(int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++)
{
cout << argv[i];
if (i < argc - 1)
cout << " ";
}
cout << endl;
return 0;
}
No comments :
Post a Comment