Hi developers,
I'm running GCC (GNU C/C++ Compiler shipped with Fedora Core 2). I've
written a program using IOStream classes, in which I'm reading files in
ios::binary mode. I'm using read() method (exact signature not
remembered) of the std::istream class ? When I'm reading the value in
objects attribute (member variable), the read fails, but when I'm
reading in a local variable value is successfully read as shown below:
..... any includes that are necessary
class a {
int magik;
public:
void go(ifstream&);
};
void a::go(ifstream& in) {
int j;
in.read((char*)&magik, sizeof(int)); // Incorrect value read in
magik
}
/*
* If instead of address of a::magik above if I'll pass the local var.
j
* the code works fine.
*/
The above code works fine on Microsoft C/C++ compiler shipped with
Microsoft Visual C++ Toolkit 2003 but fails with MingW GCC 3.4 (same
problem).
Any suggestions,
Thanks,
Ashish Shukla alias Wah Java !!
Wah Java !!