M
mwebel
Hi,
My Module (B) needs to read from a istream (provided by another module
A) and again the module (C) i use accepts only char*.
So actually it accepts filenames. But i dont want to store the stream
onto the disk and pass it again. I am also not allowed to change the
API on the module i use. I can chang the way it works though.
So i thought i'd cheat by storing the stream adress in the char and
restoring it again once "inside" the code.
so my basic question is: Would this work?
heres the code id use:
//supossing i get a istream
istream in("test.txt");
//i store its adress as a char
char* d=(char*)∈
//inside the code i create a pointer
istream * t;
//and restore its adress back
t=(ifstream*)d;
using the code above with fstreams i achieve to read a file.
the thing is, that after my module is done the module A deletes and
deallocates the stream.
AFAIK there should not be a problem with this. because all i do is only
read operations.
can anyone reassure me on this?
thx in advance
My Module (B) needs to read from a istream (provided by another module
A) and again the module (C) i use accepts only char*.
So actually it accepts filenames. But i dont want to store the stream
onto the disk and pass it again. I am also not allowed to change the
API on the module i use. I can chang the way it works though.
So i thought i'd cheat by storing the stream adress in the char and
restoring it again once "inside" the code.
so my basic question is: Would this work?
heres the code id use:
//supossing i get a istream
istream in("test.txt");
//i store its adress as a char
char* d=(char*)∈
//inside the code i create a pointer
istream * t;
//and restore its adress back
t=(ifstream*)d;
using the code above with fstreams i achieve to read a file.
the thing is, that after my module is done the module A deletes and
deallocates the stream.
AFAIK there should not be a problem with this. because all i do is only
read operations.
can anyone reassure me on this?
thx in advance