Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- // 1c.______________________________________
- float pi = 3.1415926;
- char* s = "kerulete";
- double m = 6.23768e+24;
- printf("%.2f %12s %.3e", pi, s, m);
- printf("\n");
- // 2c.______________________________________
- int u1;
- double v1,v2;
- FILE* input;
- // Eloszor kiirjuk, hogy tesztelhessuk.(zh-n nem kell)
- // Igen, igy konnyebb, mint manual megnyitni es beleirni...xd
- /*
- input = fopen("in.txt","w");
- if(input == NULL){
- perror(input);
- //abort();
- }
- fprintf(input,"%d %f %f", 10, 10.123123, 12.123123);
- fflush(input);
- */
- input = fopen("in.txt","r");
- if(input == NULL){
- perror(input);
- //abort();
- /* itt abortolható lehetne a program,
- ha csak ez a feladat szerepelne benne. */
- }
- fscanf(input,"%d %lf %lf", &u1, &v1, &v2 );
- fclose(input);
- printf("%d %lf %lf\n", u1, v1, v2);
- // 3c.______________________________________
- int error = 666;
- fprintf(stderr,"A hibakod: %8X\n", error);
- // 4c.______________________________________
- double kiA[6] = {1.1,1.2,1.3,1.4,1.5,1.6};
- double beA[6];
- FILE* inputB;
- // Eloszor kiirjuk, hogy tesztelhessuk.(zh-n nem kell)
- /*
- inputB = fopen("a.bin","wb");
- if(inputB == NULL){
- perror(inputB);
- //abort();
- }
- fwrite(kiA, 6*sizeof(double), 1, inputB);
- fflush(inputB);
- */
- inputB = fopen("a.bin","rb");
- if(inputB == NULL){
- perror(inputB);
- //abort();
- }
- fread(beA, 6*sizeof(double), 1, inputB);
- fclose(inputB);
- int i;
- for(i = 0; i < (int) (sizeof(beA) / sizeof(*beA)); i++){
- printf("%.1lf ", beA[i]);
- }
- // i < 6 is boven eleg persze, csak igy "ujrafelhasznalhatobb"
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement