int main()
{ int a, b, c, d, e, f;
ofstream fr(CRfv);
ifstream fd(CDfv);
fr.close();
fd >> a >> b >> c >> d;
e = a*b;
f = c*d;
fr << e << f;
fd.close();
}
No, you've closed your stream before it's open (possible exception error) and then written/read to it when it's closed.
You need something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
fr.open();
fd.open();
if(fd.good()) // stream is open and not end of file
{
// read code here
}
if(fr.is_open()) // stream is open for writing
{
// write code here
}
fr.close();
fd.close();