Advertisement
Toliak

task3

Dec 18th, 2018
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.     FILE *fp;
  8.  
  9.     fp = fopen("task3.txt", "r");
  10.  
  11.     int amount;
  12.     fscanf(fp, "%d", &amount);
  13.  
  14.     for (int i = 0; i < amount; i++) {
  15.         char subname[256];
  16.         float height;
  17.         float weight;
  18.  
  19.         fscanf(fp, "%s", subname);
  20.         fscanf(fp, "%f", &height);
  21.         fscanf(fp, "%f", &weight);
  22.  
  23.         printf("%d student:\n", i);
  24.         printf("Subname: %s\n", subname);
  25.         printf("Height: %f\n", height);
  26.         printf("Weight: %f\n\n", weight);
  27.     }
  28.  
  29.     fclose(fp);
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement