Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <fcntl.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. void main(int argc, char *argv[]) {
  8. int file = open("data.txt", O_WRONLY | O_APPEND);
  9. char bufor[1024];
  10. memset(&bufor[0], 0, sizeof(bufor));
  11. char znak[1];
  12. int licznik = 0;
  13.  
  14. char output[1024];
  15.  
  16. if(file != 0)
  17. {
  18. while(1)
  19. {
  20. read(0,znak,1);
  21. if(znak[0] == 27)
  22. {
  23. licznik = sprintf(output, "%s", bufor);
  24. write(file, output, licznik);
  25. break;
  26. }
  27. bufor[licznik] = znak[0];
  28. licznik++;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement