![]() ![]() | io/fw2.c - Skrivning af en struct til en binær fil. | Lektion 13 - slide 31 : 32 Program 1 |
#include <stdio.h> struct str { int f1; double f2; char f3; char f4[4]; }; int main(void){ FILE *ofp; struct str rec= {5, 13.71, 'c', "xyz"}; ofp = fopen("data", "w"); fwrite(&rec, sizeof(struct str), 1, ofp); fclose(ofp); printf("The file named data has been written\n"); return 0; }