Evening all,
I have a quick question about the _read function. I am trying to read in a large data set into a character buffer. The data is stored in binary format. The size of the input data file is approximately 7 Mb, I have declared that the buffer should be 10 Mb. The code used is below, I am using MSVS 2003 in C++.
This code works to some extent. However, no matter what value I give for nbytes, the variable bytes always returns 112. This is causing me some concern as it is evident that all the data is not being read into the buf. Whenever I count into the buffer beyond a certain value of bytes I cannot access the data that I know should be there.
Is there a limit to the size of a file that can be read into a buffer using _read?
Can anybody suggest a solution to the problem?
I have a quick question about the _read function. I am trying to read in a large data set into a character buffer. The data is stored in binary format. The size of the input data file is approximately 7 Mb, I have declared that the buffer should be 10 Mb. The code used is below, I am using MSVS 2003 in C++.
Code:
char BUF[1024*1024*10];//10 Mb buffer
int main(){
char *buf=BUF;//pointer to the buffer
int file=_open("file.dat",_O_RDONLY,_S_IREAD);
if(file==-1){
perror("Failed to open file");
}
else{
cout<<"File is open\n";
int bytes;
unsigned int nbytes=(1024*1024*10);
bytes=_read(file,(void *)buf,nbytes);
}
}
Is there a limit to the size of a file that can be read into a buffer using _read?
Can anybody suggest a solution to the problem?
Comment