×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: C
Posted by: Damian Pytkowski
Added: May 2, 2016 8:39 PM
Views: 8
Tags: copy files fseek
fseek
majk -> kjam
  1. #include <locale.h>
  2. #include <stdio.h>
  3. #include <wchar.h>
  4. #include <windows.h>
  5. #include <utf8proc.h>
  6.  
  7. void kopiuj(char *skad, char *dokad);
  8. void main()
  9. {
  10.     kopiuj("nowy1.txt","nowy2.txt");
  11. }
  12. void kopiuj(char *skad, char *dokad)
  13. {
  14.     FILE *fr,*fw;
  15.     char c;int i=-1;
  16.     if((fr = fopen(skad, "r"))==NULL)printf("Blad otwarcia.");
  17.     if((fw = fopen(dokad, "w"))==NULL)printf("Blad zapisu.");
  18.     fseek(fr,i,SEEK_END);
  19.     while(1){
  20.         c=fgetc(fr);
  21.         i--;
  22.         fseek(fr,i,SEEK_END);
  23.         fputc(c,fw);
  24.         printf("%d\n",ftell(fr));Sleep(100);
  25.     }
  26.     fseek(fr,0,SEEK_SET);
  27.     c=fgetc(fr);
  28.     fputc(c,fw);
  29.     fclose(fr);fclose(fw);
  30. }
  31.