Seems a homework... If so, please don't expect to find in ee someone to create a code to solve the proposed problem. But, for sure we can help youn by providng directions on how to solve it by yourself.
The first thing is to understand how to capture the arguments.
In C/C++ we use the simple code below:
int main(int argc, char **argv)
where argc is the number of arguments.
It counts the name of the program, so if the user just starts the program without passing any argument, argc will be equal to one. If you use the code below:
printf("\nThis program has %d arguments\n",argc);
and run the program without any argument, the result will be
This program has 1 arguments
If you want to check if there are arguments, just check if argc is > 1.
If so, you can print the second argument (assuming the program's name as the first one) by using:
if (argc == 2)
{
printf("the argument is %s\n",argv[1]);
}
Why to use argv[1] to print the argument? Because argv is an array of strings, and you want to print the argument. If you want to print the program's name, which is the index between the brackets?
Well, you know how to determine if there is one and just one argument...
To print it you can chose the "c" printf (as in the sample above) or "c++" cout.
Now, how to print if in reverse order?
To do it, you need to study a nit more about strings, actually char arrays in C.
In this subject, I'm not very sure if you need to work with AnsiString os char*. For simplicity, I'll suggest to use char*
As a char array is something like
char *str = "a1B";
being str[0] = 'a', str[1]='1', and so on, then if you make a for loop, like
for (int i=0; i<strlen(str);i++) printf("\n%s",str[i]);
then it will print
a
1
B
If you make the loop in reverse counting, say, staring with at last character and finisshing at the first, the loop would be
for (i=lenght-1; i>=0;i--)
thus the chars will be picked in reverse order...
To complete your exercise, to substitute the numeric characters, you can use a sequence as in the pseudocode below
foreach ch in str (in reverse order)
{
if (ch == '1') print 'One"
else if (ch == '2') print "Two"
etc.
}
or use the switch:
{
switch (ch)
{
case '1': print "One"; break;
case '2': .... etc
default: print ch;
}
}
Jose