Created
January 8, 2014 09:39
-
-
Save satishgoda/8314174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <algorithm> | |
#include <iterator> | |
#include <cstdlib> | |
int main(int argc, char* argv[]) | |
{ | |
using namespace std; | |
for(auto arg = argv+1; *arg not_eq nullptr; ++arg) { | |
cout << *arg << endl; | |
} | |
cout << endl; | |
for(const auto& arg : vector<string> {argv+1, argv+argc}) { | |
cout << arg << endl; | |
} | |
cout << endl; | |
copy(argv+1, argv+argc, ostream_iterator<char *>(cout, "\n")); | |
cout << endl; | |
vector<string> cmdlineargs {argv+1, argv+argc}; | |
copy(cmdlineargs.cbegin(), cmdlineargs.cend(), ostream_iterator<string>(cout, "\n")); | |
cout << endl; | |
copy(cmdlineargs.crbegin(), cmdlineargs.crend(), ostream_iterator<string>(cout, "\n")); | |
cout << endl; | |
reverse_copy(cmdlineargs.crbegin(), cmdlineargs.crend(), ostream_iterator<string>(cout, "\n")); | |
return EXIT_SUCCESS; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment