Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <sys/stat.h>
  4. #include <fcntl.h>
  5. #include <string.h>
  6. #include <errno.h>
  7. #include <stdlib.h>
  8. #include <time.h>
  9. #include <unistd.h>
  10. #define BUFFERGROOTTE 20
  11.  
  12. int main(){
  13.  
  14. int descriptor = open("test.txt", O_WRONLY | O_CREAT | O_APPEND, S_IWUSR);
  15. if(descriptor < 0){
  16. printf("Er is een fout gebeurd bij het inlezen");
  17. } else {
  18.  
  19. srand(time(NULL));
  20. int i = 0;
  21. for(i; i < 500000; i++){
  22.  
  23. char letter = 'a' + rand() % 26;
  24. char buffer[BUFFERGROOTTE];
  25. int j = 0;
  26. for(j; j < 20; j++){
  27. buffer[j] = letter;
  28. }
  29. write(descriptor, buffer,1);
  30.  
  31. }
  32. close(descriptor);
  33.  
  34.  
  35. }
  36.  
  37. return 0;
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement