Sebastian Becker wrote:
is fscanf capable of reading a memory adress from a file? I tried to
find the right format-parameter, but my code doesn't seem to work...
Any number can mean whatever you make it mean. For example, something
like 0x10000000 on Windows may mean the address from which a DLL is
loaded. It may actually be a valid address once you read that number
from a file and convert into an address.
When a program runs, objects in it are located at some addresses that
can be converted to numbers (long is usually large enough to represent
any object pointer value). While the program is running you can write
those values to a file and later (while the program is still running)
retrieve them from that file and use after converting back to pointers.
It is possible that those addresses will stay valid during the run of
the program, and you can actually know that yourself: pointers' lives
are well defined.
When the program exits, finishes, the memory it used to occupy and use
for the objects, is usually freed. Nothing can guarantee that the next
run of the same program will mean that the same objects are located at
the same memory addresses, generally.
So, the answer to your question is probably: while it is possible for
your program to store and retrieve addresses in/from files, there is no
much sense in doing that.
V