Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define IMEDAT "dionice.dat"
- typedef struct {
- int redni_broj;
- char naziv_postaje[13+1];
- int udaljenost;
- } klasa;
- int citaj_dat(FILE *dat) {
- klasa autoput;
- printf("r.br. Naplatna postaja udaljenost(km)\n====================================\n");
- while (fread(&autoput, sizeof(autoput), 1, dat) == 1)
- {
- printf("%3d\t%12s\t %6.3f\n", autoput.redni_broj, autoput.naziv_postaje, (float) autoput.udaljenost / 1000);
- }
- return autoput.redni_broj;
- }
- int main () {
- FILE *inputfile = NULL;
- int broj_dionica;
- char ime[13+1];
- if ((inputfile = fopen(IMEDAT, "rb")) == NULL)
- {
- printf("Doslo do je do pogreske u otvaranju datoteke %s.\n", IMEDAT);
- exit(0);
- }
- broj_dionica = citaj_dat(inputfile);
- printf("\n\nBroj procitanih dionica: %d.\n", broj_dionica);
- fclose(inputfile);
- return 0;
- }
Add Comment
Please, Sign In to add comment