Re: Faster way to write in a file



santosh wrote:
LilacSkin wrote:

Hi,

Currently, I write an signed long long in a file with the fprintf
function:

signed long long * pData = NULL;
unsigned long long k = 0;
unsigned long DataAvail = 0 ;

pDataRx = (signed long long *) malloc ( sizeof(signed long long ) *
(65536*16*8) / 8);

for ( k = 0; k < DataAvail/8; k ++ ) {
fprintf ( pFilec, "%lli\t", pData[k]);
}

The problem is that function is very very slow !

In several forums, I saw that fwrite function is better, but I don't
know how to use it.
Can you help me, please ?

size_t rc;
rc = fwrite(pData, sizeof *pData, 1048576UL, pFilec);
if (rc != 1048576) {
puts("Write error.");
/* ... */
}

How does dumping the data in binary form compare to writing a
tab-delimited textual representation?
.



Relevant Pages

  • Re: Faster way to write in a file
    ... "LilacSkin" wrote in message news ... I write an signed long long in a file with the fprintf ... signed long long * pData = NULL; ...
    (comp.lang.c)
  • Faster way to write in a file
    ... I write an signed long long in a file with the fprintf ... signed long long * pData = NULL; ... In several forums, I saw that fwrite function is better, but I don't ...
    (comp.lang.c)
  • Re: Faster way to write in a file
    ... LilacSkin wrote: ... I write an signed long long in a file with the fprintf ... signed long long * pData = NULL; ... rc = fwrite(pData, sizeof *pData, 1048576UL, pFilec); ...
    (comp.lang.c)