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++.
Expand|Select|Wrap|Line Numbers
- 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?