Skip to content

Instantly share code, notes, and snippets.

@recuraki
Created October 30, 2020 12:23
Show Gist options
  • Save recuraki/f95a15744f8251fe56b8829df29d62ed to your computer and use it in GitHub Desktop.
Save recuraki/f95a15744f8251fe56b8829df29d62ed to your computer and use it in GitHub Desktop.
C++でのargc, argv
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
//////////////////////////////////////
#include <iostream>
using namespace std;
#define dp(arg) do { cout << #arg << ":"; dprint(arg); } while(0)
template <typename T> void dprint(T arg) { cout << arg << "\n"; }
template <typename T> void dprint(const vector<T>& arg) { for_each(begin(arg), end(arg), [](T value){ cout << value << " "; } ); cout << "\n"; }
template <typename T> void dprint(const vector<vector<T>>& arg) { for_each(begin(arg), end(arg), [=](vector<T> arg2){ dprint(arg2); cout << "\n";} ); }
//////////////////////////////////////
int main(int argc, char *argv[]) {
string arg[argc];
REP(i, argc) arg[i] = string(argv[i]);
REP(i, argc) {
cout << "argument[" << i << "]: " << arg[i] << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment