#include "libscl.h"

using namespace std;
using namespace scl;

int main(int argc, char** argp, char** envp)
{

 // A better way, vectors are discussed in Chapter 3.

  vector<string> arguments;

  char** ptr = argp;
  char** top = argp + argc;
  while (ptr < top) arguments.push_back(*ptr++);

  vector<string> environment;

  ptr = envp;
  while (*ptr) environment.push_back(*ptr++);

  ofstream fout;
  fout.open("arg.txt");
  if (!fout) error("Error, cannot open fout");

  vector<string>::size_type i = 0;
  while (i != arguments.size()) fout << arguments[i++] << '\n';
  fout << '\n';

  fout.close(); fout.clear();

  fout.open("env.txt");
  if (!fout) error("Error, cannot open fout");

  i = 0;
  while (i != environment.size()) fout << environment[i++] << '\n';

  fout.close(); fout.clear();

  return 0;
}
