-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIteratorFunction.cpp
More file actions
42 lines (33 loc) · 1.09 KB
/
IteratorFunction.cpp
File metadata and controls
42 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* \file IteratorFunction.cpp
* \brief
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//--------------------------------------------------------------------------------------------------
int main(int, char **)
{
// Initializing string`
std::string str = "geeksforgeeks";
// Declaring iterator
// Displaying string
std::cout << "The string using forward iterators is : ";
for (std::string::iterator it = str.begin(); it != str.end(); ++ it) {
std::cout << *it;
}
std::cout << std::endl;
// Declaring reverse iterator
// Displaying reverse string
std::cout << "The reverse string using reverse iterators is : ";
for (std::string::reverse_iterator it1 = str.rbegin(); it1 != str.rend(); ++ it1) {
std::cout << *it1;
}
std::cout << std::endl;
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------
#if OUTPUT
The string using forward iterators is : geeksforgeeks
The reverse string using reverse iterators is : skeegrofskeeg
#endif