Is it possible to have a pointer to something (say a string) that is on the hard disk?

Recommended Answers

All 3 Replies

In a way that's the only way to read from disk. If you are interested in how to do file I/O manually then I suggest you get familiar with the C++ functions fput, fget, fseek, etc. If you are asking whether sth like double* pDbl can be made to point to a location on the hard-drive then normally no. Pointers point to the programs memory space, but I'm pretty sure with some hackery you could force it to point to storage. Why would you want to do that, though? a pointer is normally a 4-byte word on 32-bit-machines and a 8-byte word on 64-bit-machines. the addressable storage with those pointers would be rather too small for todays hard-drives of a terra-byte size or so.
with a pointer you could only access a fraction of that.

No reason, just wondering. Thanks for your answer.

Is it possible to have a pointer to something (say a string) that is on the hard disk?

For a very liberal definition of "pointer", yes. But if you mean a C++ pointer type, no.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.