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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy/Load memory block<->file

Status
Not open for further replies.

schbounz

Programmer
Aug 25, 2002
11
FR
Hello,

I need to copy a whole memory block into a file, and also be able to load it later from the file.

How could I do this ?

Thanks

 
Look at memcpy, memccpy and their family. If you are using C++ Builder, look at TMemoryStreams. James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
memcpy and memccpy copy a buffer to another buffer, not to a file.

TMemoryStream seems to do what I want to do but is Borland-specific.

But how can I do using "pure" c++ syntax ?

Thanks

 
You should be able to link the buffer to a file with either streams or something like fprint.
James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top