I am working on a project, and need to display a string backwards. I have gotten it to where it will display the last letter in the string, "num" times, and "num" equals the length of the string. The problem I am having is it only shows the last number. Here is my instructions on this part.
"Using a loop and the square-bracket [] notation to access each individual character in the string, display the string backwards (last character in the string first, next to last, etc). Remember that the character positions in a string are numbered starting with 0, so the first position in the string would be stringname[0], while the last position in the string would be stringname[stringname.length()-1]. Also remember that individual positions in a string can be referenced using integer variables, such as an integer counter for a loop that goes from stringname.length()-1 down to 0."
This is what I have so far:
Code:
counter = 0;
do {
counter++;
cout << Char[Char.length()-1];
} while (counter < num);
Any help would be appreciated, I just need to get pointed in the right direction and it should come fairly easy. Thanks!