/* clean.cpp -- Given as command line parameter a filename,
 *              it removes from that file all occurrences of ^M
 *              If 'clean' is the executable image of this
 *              program, you can use it as follows:
 *                 % clean dirtyfile > cleanfile
 */

#include <iostream>
#include <fstream>

int main(int argc, char *argv[])
{
  if(argc!=2){
    cout << "Usage: " << argv[0] << " filename\n";
    exit(0);
  }
  const int CONTROLM = 13;
  char c;
  ifstream fd(argv[1]);

  if( !fd ){
    cout << "Error in open\n";
    exit(1);
  }
  while(fd.get(c))
    if (c!=CONTROLM)
      cout.put(c);
  fd.close();
}
