Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct exchangeRate
- {
- float bynToUsd;
- float usdToByn;
- float bynToEur;
- float eurToByn;
- };
- int main()
- {
- struct exchangeRate* rate = malloc(sizeof(struct exchangeRate));
- FILE* f = fopen("d:\\db.bin", "rb");
- if (f == NULL)
- {
- f = fopen("d:\\db.bin", "wb");
- rate->bynToUsd = 10;
- rate->usdToByn = 11;
- rate->bynToEur = 12;
- rate->eurToByn = 13;
- fwrite(rate, sizeof(struct exchangeRate), 1, f);
- fclose(f);
- return 0;
- }
- fread(rate, sizeof(struct exchangeRate),1, f);
- printf("%.4f\n", rate->bynToUsd);
- printf("%.4f\n", rate->usdToByn);
- printf("%.4f\n", rate->bynToEur);
- printf("%.4f\n", rate->eurToByn);
- fclose(f);
- free(rate);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement