blob: 7542022f40ab6e221fdf6a8dd7b53665ffe26980 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <stdio.h>
#include <stdbool.h>
#include "primes.h"
#define FILENAME "/assets/primes_table"
bool read_table(unsigned char *table) {
FILE *f = fopen(FILENAME, "rb");
if (f == NULL)
return false;
int b = fread(table, TABLESIZE, 1, f);
fclose(f);
return b == 1;
}
bool store_table(const unsigned char *table) {
FILE *f = fopen(FILENAME, "wb");
if (f == NULL)
return false;
int b = fwrite(table, TABLESIZE, 1, f);
fclose(f);
return b == 1;
}
|