Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int zad5(char name[], int rows)
- {
- FILE* jp;
- if ((jp = fopen(name, "r")) == NULL)
- {
- printf("cos poszlo nie tak");
- exit(1);
- }
- float* arr;
- arr = malloc(50 * sizeof(float));
- int i = 0;
- while (i < rows)
- {
- fscanf(jp, "%f", &arr[i]);
- ++i;
- }
- for (int a = 0; a < (rows / 3); a++)
- {
- printf("\n");
- for (int b = (a * 3); b < ((a + 1) * 3); b++)
- {
- printf("%.2f\t", arr[b]);
- }
- }
- return arr;
- free(arr);
- fclose(jp);
- }
- int main()
- {
- zad5("macierz2.txt", 12);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement