Skip to content

Instantly share code, notes, and snippets.

@satishgoda
Created January 8, 2014 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satishgoda/8314174 to your computer and use it in GitHub Desktop.
Save satishgoda/8314174 to your computer and use it in GitHub Desktop.
#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