Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 3395

How to read and write Huge files with GMP ? I need great processing of data in files as binary

$
0
0
Hello

I need to process files' data for my application , When it comes to huge data , C language can't handle them and I must write my own library for huge numbers and data but GMP is a good choice for this manner . Also I need functions for reading/writing sectors of HDD or SSD as huge amount of data for my application . I write this piece of code by GMP manual but it writes only " 0 " and as ASCII ( text ) ..... Is there any way to read/write files and sectors as binary and also my code doesn't work ( 0 as result ) :

Code:

#include <stdio.h>#include <gmp.h>int main(void){FILE * fr, * fw; // two file pointers prepared for creationchar filename[100]; // a string for file name of input and output filesprintf("Enter file's name : ");scanf("%s", filename); // taking file name of inputfr = fopen(filename, "rb+"); // opening file fr for reading as binaryprintf("Enter copied filename :");scanf("%s", filename); // taking file name of outputfw = fopen(filename, "wb+"); // opening file fw for writing as binarympz_t x; // a big integer decalredmpz_t y; // also ympz_init(x); // initialization of x to 0mpz_init(y); // also ygmp_fscanf(fr, "%Zd", y); // file scanning of input file as huge decimal and store it in ympz_set(x, y); // assigning y in x --- or should it be as a must an explicit number and not variable ?gmp_fprintf(fw, "%Zd", x); // writing x to a filempz_clear(x); // clearing and emptying xmpz_clear(y); // also yfclose(fr); //closing frfclose(fw); // closing fwreturn 0;}

Statistics: Posted by Hadi_Lovelorn — 2024-06-21 22:30 — Replies 0 — Views 17



Viewing all articles
Browse latest Browse all 3395

Trending Articles