I know that I can do this way, but I have to write in c++ code. I have a show function void show() which is showing the data. I want to save this data in file. I try this:
fileout<< show();,It didn't work
I am getting this error:
error C2679: binary '<<' : no operator defined which takes
a right-hand operand of type 'void' (or there is no acceptable conversion)
Here is my code:
const char FOUT[]="C:\\test .dat";
ofstream outs(FOUT);
if (!outs)
{ cout<< "Unable to Open the file "<<FOUT<< endl;}
else if (outs.is_open())
{
for(int f=0;f<SIZE;f++)
{outs<< cat[f].print()<< flush; }
}
outs.close();
}
it means your function print() is void. Change return type to some string type, accumulate all outputs in a string variable, and write them in the file, or put the file as a parameter to function and write inside the function:
1.
string print()
{
str x;
cout<< something;
x += something;
.....
return str;
}
or
2.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.