#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
class lohi
{
int x;
int y;
public :

lohi()
{
x=10;
y=20;
}

}X;
int main()
{
fstream io;
io.open("just1",ios::in | ios:: out | ios::app);
io.write((char*)&X,sizeof(X));
io.close();
}

in this programme i expect a file to be created and contents of x,y to be in it........
but................................................................................................................
its not at all creating a file ..
brothers please help

Flush the io.

how to flush ............... tell me
syntax , im new to c++

some one please write answer

#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
class lohi {
	int x;
	int y;
public:
	lohi() {
		x=10;
		y=20;
	}

} X;
int main() {
	fstream io;
	io.open("just1", ios::out | ios::app);
	io.write((char*)&X, sizeof(X));
	io.close();
}
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.