How to read data from several files into a single buffer?
- From: "gregus" <diego.arias.vel@xxxxxxxxx>
- Date: 31 Oct 2005 10:42:42 -0800
Hi everyone!!!
I want to read data from several files into a single buffer. How can I
do this???
I have something like this:
//...
typedef unsigned short word;
const unsigned int W_SIZE = sizeof(word);
//...
void RecoveryFile(int nfiles)
{
//I know the number of files (rows) and its path.
//Every path is stored in a list and I can access them as list[i]
//aditionally every file size is blocksize.
word *mydata = (word*) calloc(rows*blocksize,W_SIZE);
if (mydata == NULL) { perror("malloc - mydata"); exit(1);}
for(i=0; i<nfiles; i++)
{
f = fopen(list[i], "rb"); // I need the binary mode
if (f == NULL) { perror(" file missing"); exit(1);}
else
{
fread(??????,W_SIZE,(blocksize/2),f);//How???
}
fclose(f);
}
//... process mydata
free(mydata);
}
Any help would be very much appreciated
Thanks in advance.
--DMA
.
- Follow-Ups:
- Re: How to read data from several files into a single buffer?
- From: Skarmander
- Re: How to read data from several files into a single buffer?
- Prev by Date: Re: Can you recommend any C programming books?
- Next by Date: Re: Why this code is working
- Previous by thread: Syscall problem ?
- Next by thread: Re: How to read data from several files into a single buffer?
- Index(es):