What is the recommended method for wrapping “int main(int argc, char** argv)” ?
Thanks,
Oran
// test.C
#include
#include
#include
#include
using namespace std;
int main(int argc, char** argv) {
if (argc < 3)
return(EXIT_FAILURE);
ifstream in(argv[1]);
ofstream out(argv[2]);
if (!in || !out)
return(EXIT_FAILURE);
char c;
while (in.get©) {
if (c == ‘\t’)
out << " "; // 3 spaces
else
out << c;
}
out.close( );
if (out)
return(EXIT_SUCCESS);
else
return(EXIT_FAILURE);
}
void test(){
extern char *__progname;
vector<const char*> v;
v.push_back(__progname);
string s;
while (getline(cin, (s=new string()), ’ ')) {
v.push_back(s->c_str());
}
cout << main(v.size(), (char)v.data()) << endl;
}
echo “file.in file.out” | cling -std=c++11 test.C