unix格式转换成windows格式

来源:互联网 发布:radan软件操作说明书 编辑:程序博客网 时间:2024/05/10 11:42

int main(int argc, char* argv[])
{
 int ch;  
 char *file1 = "c://e1.txt";
 char *file2 = "c://e.txt";
 FILE *in = NULL;
 FILE *out = NULL;
 if (!(out = fopen(file1,"wb+")))
 {
  return 1;
 }
 if (!(in = fopen(file2,"rb+")))
 {
  return 1;
 }
  
 while ((ch = fgetc(in))!=EOF)
 {  
  if(ch=='/n')
  {
   fputc('/r',out);
   fputc('/n',out);
  }
  else
  {
   fputc(ch,out);
  }
 }

 fclose(in);  
 fclose(out);

 DeleteFile(file2);
 rename(file1,file2);
     

   return 0;

}