Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
10
Добавлен:
26.05.2014
Размер:
1.34 Кб
Скачать
//This program converts text file in DOS format into UNIX format and vice versa


#include <stdio.h>

main(argcount,fname)
  int argcount;
  char *fname[];

{
 FILE *in, *out;
 int ch;

if (argcount==1)
{ printf("conform <file1> <file2> <key> \n");
  printf(" <file1>: Source text file; \n");
  printf(" <file2>: Result text file (may not be exist!); \n");
  printf(" <key>: Option keys: \n");
  printf("  -d Into DOS format; \n");
  printf("  -u Into UNIX format; \n");
}

else
   {
    printf(" %d", strcmp(fname[3],"-u"));

   if (argcount<3)
     printf("Need source filename or key. \n");
   else
     if (
         (strcmp(fname[3],"-u")==0)
         ||
         (strcmp(fname[3],"-d")==0)
        )
         if ((in=fopen(fname[1],"r"))!=NULL)
	   {
	     out=fopen(fname[2],"w");     		
	     if (strcmp(fname[3],"-u")==0)
	       while ((ch=getc(in))!=EOF)
	        if (ch!=13)
	       	  putc(ch,out);        	 
	     if (strcmp(fname[3],"-d")==0)
	       while ((ch=getc(in))!=EOF)
	        if (ch==10)
	   	  {
		   printf("ok\n");
                   putc(13,out);
		   putc(ch,out);
		  }
	        else
		  putc(ch,out);
	     fclose(in);
	     fclose(out);
	   }
         else
	   printf("Can't open file %s. \n",fname[1]);
     else
       printf("Invalid key.\n");
}
}
Соседние файлы в папке tarasov