Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

put pointer on a file

Status
Not open for further replies.

vladimir99

Programmer
Oct 9, 2001
2
FR
Hello,

I need to put in memory a file, and to put a pointer on the beginning of the memory zone.

How can I do ?
 
If I read you correctly, you want to read a file into storage, and get a pointer to the start of the file. Here's one way:

void readFile()
{
unsigned char* pBuff;
int fp = _open("c:\\test.dat",_O_RDONLY|_O_BINARY);
if (fp>0)
{
// read file
long len = _filelength(fp);
pBuff = new char[len];
_read(fp,pBuff,len);
}
_close(fp);
// Do something with data...
delete [] pBuff;
}

after _read() pBuff points to start of data.
:) Hope that this helped! :)
 
Thanks for you answer.

But in fact I want to point a file locate in my memory, but not on my hard drive (i explain more : my global project is to display a jpeg proprieties in a propreties page, for that purpose i have to load a picture from a data base, it will be charged on memory and then treated, that's why i need to point to the begin of that memory).

thank's in advance.
 
I'm still not quite clear about what you want. You might want to take a look at memory mapped files, though. :) Hope that this helped! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top