From 1783b160241303a8a3aca5d1ce361b60023a59d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Mon, 26 Dec 2016 16:51:51 +0100 Subject: [PATCH] Use raw I/O for file saving. --- src/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 8de0c3b..82ea84a 100644 --- a/src/main.c +++ b/src/main.c @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Failed to open primes file `%s'.\n", ifile); goto releaseMemory; } - while(mpz_inp_str(num, pFile, base) != 0) { + while(mpz_inp_raw(num, pFile) != 0) { addToList(&primes, num); } if(fclose(pFile) != 0) { @@ -163,11 +163,10 @@ nextPrime: printf("Writing primes to `%s'...\n", ofile); puts("0%"); for(size_t i = 0; i < primes.end; ++i) { - if(mpz_out_str(outFile, base, primes.list[i]) == 0) { + if(mpz_out_raw(outFile, primes.list[i]) == 0) { fprintf(stderr, "Error occurred while writing to file `%s'.\n", ofile); goto releaseMemory; } - fprintf(outFile, "\n"); if(i == primes.end / 4) puts("25%"); else if(i == primes.end / 2) puts("50%"); else if(i == primes.end * 3 / 4) puts("75%");