Guest User

Untitled

a guest
May 28th, 2016
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "realezat.h"
  5. int reshift (char* in, char* out, int n)
  6. {
  7.   int i, q;
  8.     char buf[8], el[1], buf2[8]={'i','n','c','l','u','d','e','<'};
  9.   char* namef;
  10.   FILE *input;
  11.   FILE *output;
  12.   if(n==1000)
  13.   {
  14.     printf("!!!!!!!!!!\n");
  15.     return 0;
  16.   }
  17.   input=fopen(in, "r");
  18.   output=fopen(out, "w");
  19.   for(i=0; i<8&&(buf [i] = fgetc(input)) != EOF; i++)
  20.   {
  21.   }
  22.   if (i<8)
  23.   {
  24.     q=i;
  25.     for(i=0;i<q; i++)
  26.     {
  27.       fprintf (output, "%c", buf [i]);
  28.     }
  29.      fclose (input);
  30.     fclose (output);
  31.     return 0;
  32.   }
  33.   while ((el[0]=fgetc(input))!=EOF)
  34.   {    
  35.    
  36.         if (0!=strcmp(buf, buf2))
  37.     {
  38.             fprintf(output, "%c",buf[0]);      
  39.         for(i=0; i<7; i++)
  40.         {
  41.           buf[i]=buf[i+1];
  42.         }
  43.         buf[7]=fgetc(input);
  44.         }
  45.         else
  46.     {
  47.       i=1;
  48.      namef = (char*) realloc (namef, sizeof(char)*i);  
  49.       while((namef [i] = fgetc(input)) != '>'  && namef [i]  != EOF  )
  50.       {
  51.           i++;
  52.           namef = (char*) realloc (buf, sizeof(char)*i);        
  53.       }
  54.       if(namef[i]==EOF)
  55.       {
  56.         return 1;
  57.        
  58.       }
  59.       else
  60.       {
  61.         n++;
  62.         if(reshift(namef, out, n))
  63.         {
  64.         }
  65.         else
  66.         {
  67.           return 0;
  68.         }
  69.            namef = (char*) realloc (buf, sizeof(char)*1);        
  70.       }
  71.      
  72.     }  
  73.   }
  74.     fclose (input);
  75.     fclose (output);
  76.   return 1;
  77.  
  78. }
  79.  
  80. ________________________
  81. #include <stdio.h>
  82. #include <string.h>
  83. #include <stdlib.h>
  84. #include "realezat.h"
  85. int main (void)
  86. {
  87. if(reshift("input.txt", "output.txt", 1)==0)
  88. {
  89.  
  90.   return 0;
  91. }
  92. return -1;
  93. }
  94. ___________________________________
  95. #ifndef FMODULE_H
  96. #define FMODULE_H
  97. int reshift(char* in, char* out, int n);
  98. #endif
Advertisement
Add Comment
Please, Sign In to add comment