Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. // SO IS1 211A LAB06
  2. // Maciej Doktor
  3. // dm44307@zut.edu.pl
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <fcntl.h>
  7. #include <io.h>
  8. #include <stdio.h>
  9.  
  10. int main(int argc, char * argv[]) {
  11.  
  12. int znaki, plik,r;
  13. char bufor;
  14.  
  15. for(;;) {
  16. plik = open("baza.txt", O_WRONLY | O_CREAT | O_EXCL, 0777);
  17.  
  18. if (plik < 0) {
  19. continue;
  20. }
  21.  
  22. else {
  23. r = read(0,&bufor,sizeof(char));
  24. znaki = write(plik, &bufor, sizeof(char));
  25.  
  26. close(plik);
  27. if(r == '*'){
  28. break;
  29. close(plik);
  30. }
  31. }
  32. }
  33.  
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement