Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BibTeX 1.13 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6.     FILE *f1,*f2;
  7.     char c,inc, outc, fnr[20],fnw[20];
  8.     int i,l=1,n=0,e=0;
  9.     while(1)    {
  10.         printf("1.Rotate\n2.Restore\n3.Exit\n >");
  11.         c=getchar();
  12.         switch(c){
  13.             case '1':{
  14.                 printf("File name:");
  15.                 scanf("%s",fnr);
  16.                 strcpy(fnw,fnr);
  17.                 strcat(fnr,".txt");
  18.                 strcat(fnw,"_ROT.txt");
  19.                 if((f1=fopen(fnr,"r"))==NULL || (f2=fopen(fnw,"w"))==NULL){
  20.                     printf("Unable to acyousucklolcess file(s).");
  21.                     break;
  22.                 }
  23.                 inc=fgetc(f1);
  24.                 fputc(inc,f2);
  25.                 while(!e){
  26.                     inc=fgetc(f1);
  27.                     while(inc!=EOF){
  28.                         printf("%d",l);
  29.                         if(inc=='\n'){
  30.                             n=0;
  31.                             for(i=0;i<l;i++){
  32.                                 inc=fgetc(f1);
  33.                                 if((inc=='\n')){
  34.                                     n=1;
  35.                                     break;
  36.                                 }
  37.                                 if(inc==EOF){
  38.                                     e=1;
  39.                                     break;
  40.                                 }
  41.                             }
  42.                             if(n || e){
  43.                                 inc='|';
  44.                             }
  45.                             else {
  46.                                 inc=fgetc(f1);
  47.                             }
  48.                             fputc(inc,f2);
  49.                         }
  50.                     }
  51.                     l++;
  52.                 }
  53.                 fclose(f1);
  54.                 fclose(f2);
  55.                 return 0;
  56.                 break;
  57.             }
  58.             case '2':{return 0;}
  59.             case '3':{return 0;}
  60.         }
  61.     }  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement