M
Matt
I am trying to cast an ostream reference to void* and back again. The
code below shows the problem isolated from a more complex program. It
compiles quietly but seg faults upon execution.
// ===================================================================
#include <iostream>
using namespace std;
void myprint(void *s) {
(ostream&)s << "hello, world" << endl;
}
int main(int argc, char *argv[]){
myprint((void *)cerr);
}
// ===================================================================
Why can't I cast the ostream reference to and from void*?
code below shows the problem isolated from a more complex program. It
compiles quietly but seg faults upon execution.
// ===================================================================
#include <iostream>
using namespace std;
void myprint(void *s) {
(ostream&)s << "hello, world" << endl;
}
int main(int argc, char *argv[]){
myprint((void *)cerr);
}
// ===================================================================
Why can't I cast the ostream reference to and from void*?