Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main(int argc, char *argv[]) {
  7.  
  8. printf("Hello world\n");
  9.  
  10. FILE *pz = fopen("plik.txt", "w");
  11.  
  12. //int x = '1' ;
  13. //printf("%c\n",x);
  14.  
  15.  
  16. srand(time(NULL));
  17.  
  18. int *p;
  19. int size_p = 10;
  20. char *pc;
  21.  
  22. p = malloc(size_p * sizeof(int));
  23. pc = malloc(size_p * sizeof(char));
  24.  
  25. int i = 0;
  26. int j;
  27. for (i = 0; i < size_p; i++) {
  28. p[i] = rand() % size_p;
  29. //printf("%d ",p[i]);
  30. }
  31. puts("");
  32.  
  33.  
  34. //puts(pc);
  35.  
  36. //fputs(pc,"plik.txt");
  37.  
  38. for (int i = 0; i < size_p; ++i)
  39. {
  40. fprintf(pz, "%d", p[i]);
  41. }
  42.  
  43.  
  44. free(p);
  45. free(pc);
  46. fclose(pz);
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement