(Using string Iterators) Write a program using iterators that demonstrates the use of func- tions rbegin and rend.
What will be an ideal response?
```
// Program demonstrates rend and rbegin.
#include
#include
using namespace std;
int main()
{
string s( "abcdefghijklmnopqrstuvwxyz" ); // declare string s
// re is set to the end of the reverse sequence of s
string::reverse_iterator re = s.rend();
// rb is set to the beginning of the reverse sequence of s
string::reverse_iterator rb = s.rbegin();
cout << "Using rend() string is: ";
// print from the end of the reversed string to the beginning
while ( re >= s.rbegin() )
{
cout << *re;
re--;
} // end while
cout << "\nUsing rbegin() string is: ";
// print from the beginning of the reversed string
while ( rb != s.rend() )
{
cout << *rb;
rb++;
} // end while
cout << endl;
} // end main
```
Using rend() string is: abcdefghijklmnopqrstuvwxyz
Using rbegin() string is: zyxwvutsrqponmlkjihgfedcba
You might also like to view...
All stream objects have ________ that indicate the condition of the stream.
A) error state bits B) condition statements C) markers D) intrinsic error messages E) None of the above
Word, by default, places a tab stop at every ____ mark on the ruler.
A. .25" B. .5" C. .75" D. 1"
____________________ is a technique where a new task will be started before the old task is finished.
Fill in the blank(s) with the appropriate word(s).
When you've selected and subsequently cut the range, it is copied to the ________
Fill in the blank(s) with correct word