Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define LADENIE_ZAKLADNE
- #define LADENIE_PODROBNE
- int main() {
- FILE *fr;
- float suma, cislo, sucet=0.;
- fr=fopen("suma.txt", "r");
- #if defined(LADENIE_ZAKLADNE) || defined(LADENIE_PODROBNE)
- printf("Otvaranie suboru\n");
- #endif
- if(fr==NULL)
- {
- exit(1);
- }
- else
- {
- #ifdef LADENIE_PODROBNE
- printf("Subor otvoreny\n");
- #endif
- ;
- }
- #if defined(LADENIE_ZAKLADNE) || defined(LADENIE_PODROBNE)
- printf("Kontrola sumy");
- #endif
- fscanf(fr,"%f", &suma);
- while(!(feof(fr)))
- {
- fscanf(fr,"%f", &cislo);
- sucet+=cislo;
- #ifdef LADENIE_PODROBNE
- printf("Suma: %f\n", sucet);
- #endif
- }
- #if defined(LADENIE_ZAKLADNE) || defined(LADENIE_PODROBNE)
- if(suma==sucet)
- printf("Suma je spravna\n");
- else
- printf("Suma je nespravna\n");
- #endif
- printf("Suma skontrolovana\n");
- #if defined(LADENIE_ZAKLADNE) || defined(LADENIE_PODROBNE)
- printf("Zatvaranie suboru\n");
- #endif
- if(fclose(fr)==EOF)
- exit(1);
- else
- #ifdef LADENIE_PODROBNE
- printf("Subor zatvoreny\n");
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement