I want the following values to be written into the file using ostream???
int main ()
{
FILE * pFile;
pFile = fopen ("myfile.txt","w");
if (pFile!=NULL)
{
fputs ("fopen example",pFile);
fclose (pFile);
}
pFile<< "r "<<" " <<"ggjjsss" <<'_'<<"gggjj"<< " " << "HLLO " <<endl;
}
I am getting the following error..
error: invalid operands of types ‘FILE*’ and ‘const char [3]’ to binary ‘operator<<‘
Since you are dealing with
FILE, I would say it’s anofstreamerror rather thanostreamerror. 🙂FILEis a C-style file i/o for whichoperator <<is not overloaded.You should use
ofstreamobject for which theoperator <<is overloaded in the library.