Sunday

C++ main function arguments, program that knows what you type on the terminal window

Program:

#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
    cout << "Number of arguments: " << argc << endl;

    cout << "You type: ";    
    for (int c=0; c<argc; c++)
    {
        cout << argv[c] << " ";
    }
    cout << endl;

    return 0;
}

Sample run:
> g++ a.cpp
> a.exe word2 word3 word4
Number of arguments: 4
You type: a.exe word2 word3 word4

No comments:

If a hater attacked your age and not the goodness of you

Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...