Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int zad5(char name[], int rows)
  5. {
  6. FILE* jp;
  7.  
  8. if ((jp = fopen(name, "r")) == NULL)
  9. {
  10. printf("cos poszlo nie tak");
  11. exit(1);
  12. }
  13. float* arr;
  14. arr = malloc(50 * sizeof(float));
  15. int i = 0;
  16. while (i < rows)
  17. {
  18. fscanf(jp, "%f", &arr[i]);
  19. ++i;
  20. }
  21.  
  22. for (int a = 0; a < (rows / 3); a++)
  23. {
  24. printf("\n");
  25. for (int b = (a * 3); b < ((a + 1) * 3); b++)
  26. {
  27. printf("%.2f\t", arr[b]);
  28. }
  29. }
  30.  
  31.  
  32. return arr;
  33. free(arr);
  34. fclose(jp);
  35.  
  36. }
  37. int main()
  38. {
  39. zad5("macierz2.txt", 12);
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement