COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/testing/eol.cpp
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 int main(int argc, char *argv[]) {
00004   if (argc!=3) return 1;
00005   FILE *fin = fopen(argv[1],"rb");
00006   if (!fin) return 2;
00007   FILE *fout = fopen(argv[2],"wb");
00008   if (!fout) return 3;
00009 
00010   char buf[1000];
00011   int r = -1;
00012   do {
00013     r = fread(buf,1,sizeof(buf),fin);
00014     if (r>0) {
00015       int len = 0;
00016       for (int i=0; i<r; i++) {
00017         if (buf[i]=='\r') continue;
00018         if (len<i) {
00019           buf[len] = buf[i];
00020         }
00021         len++;
00022       }
00023       fwrite(buf,1,len,fout);
00024     }
00025   } while (r>0);
00026 
00027   fclose(fout);
00028   fclose(fin);
00029   return 0;
00030 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines