In: Computer Science
. Consider the character array as follows:
char mySentence[] = "Hello World!";
The number of characters in the array can be determined by application of the strlen() function. Therefore, the end of the array can be determined by pointer arithmetic as follows:
char * endArray = mySentence + strlen(mySentence);
Now that the end of the array has been determined, utilise pointers in C++ to output each character in array in reverse and display it to the console window.
What other techniques could be utilised to achieve the same result? Hint: The below lines of code can be used to output the last character in the mySentence[] array once the endArray pointer has been assigned to the last element of the mySentence[] array:
char mySentence[] = "Hello World!";
char * endArray = mySentence + strlen(mySentence);
cout << (char)*(endArray - 1) << endl;