Facebook
From bily, 2 Months ago, written in C++.
Embed
Download Paste or View Raw
Hits: 43
  1.     #include <stdio.h>
  2.     typedef struct
  3.     {
  4.         int number;
  5.         char text[10];
  6.         double real_number;
  7.     } example;
  8.     int main()
  9.     {
  10.         example data = {1, "Hello!", 3.14159265}, read_data;
  11.         printf("%d %s %lf\n", data.number, data.text, data.real_number);
  12.         FILE* fout = fopen("blah.txt", "w");
  13.         fwrite(&data, sizeof(example), 1, fout);
  14.         fclose(fout);
  15.         FILE* fin = fopen("blah.txt", "r");
  16.         fread(&read_data, sizeof(example), 1, fout);
  17.         printf("%d %s %lf\n", read_data.number, read_data.text, read_data.
  18.     real_number);
  19.         fclose(fin);
  20.         return 0;
  21.     }