#include <iostream>
#include <iomanip>
using namespace std;
int Count(char* arg)
{
int count = 0;
int i = 0;
while (arg[i++] != '\0')
{
count++;
}
return count;
}
int main(int argc, char* argv[])
{
// We want at least two args.
// Remember argv[0] is the name of the program itself;
// actual args start at index 1.
if (argc < 3)
{
cout << "Provide at least two arguments to the program.\n";
return -1;
}
cout << setw(5) << "#" << setw(8) << "length" << " arg\n\n";
for (int i=0; i<argc; ++i)
{
cout << setw(5) << i << setw(8) << Count(argv[i])
<< " " << argv[i] << '\n';
}
return 0;
}