Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- // #include <fcntl.h>
- int main(int argc, char* argv[]){
- int fin = creat("a.txt",O_RDONLY);
- int fout = creat("b.txt",O_WRONLY);
- int current = 0;
- int total = lseek(fin,0,SEEK_END)
- lseek(fin,0,SEEK_SET)
- char tab[20];
- int a = 0;
- char c;
- int i = 0;
- int h1 = 1;
- int h = 1;
- while(current < total){
- i = 0;
- h1 = 1;
- while(h1 && a != -1){
- a = read(fin,&c,1);
- if(c != '\n' && a!=-1){
- tab[i] = c;
- h1 = 1;
- }
- else{
- h1 = 0;
- }
- i++;
- }
- current = current + i;
- while(i>0){
- write(fout, tab[i], 1);
- i--;
- }
- write(fout, '\n', 1);
- }
- close(fin);
- close(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement