Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- struct towar {
- char nazwa[30];
- int przecena;
- double ilosc;
- double cena;
- };
- double przecena();
- int main()
- {
- double a;
- a=przecena();
- return 0;
- }
- double przecena()
- {
- FILE *plik = fopen("magazyn.txt", "r+b");
- struct towar t;
- double proc=0, wartosc=0;
- if(plik==NULL)
- {
- printf("blad pliku");
- exit(1);
- }
- while(fread(&t, sizeof(struct towar), 1, plik) == 1)
- {
- proc=t.przecena/100;
- proc=1-proc;
- t.cena*=proc;
- wartosc+=t.cena*t.ilosc;
- }
- fclose(plik);
- return wartosc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement