May 9, 2010 at 6:35am UTC
Hi All,
I am getting the following error message while running the below given code snippet with xlC v8 compiler on AIX 5.3.
Error: Cannot convert int to FILE *
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
int fdd;
ofstream ofs;
fdd=ofs.rdbuf()->fd();
if(fdd == -1 )
cout<<"failed";
return 0;
}
Does anybody has any idea how to resolve this error?
Thanks in advance,
Sharan
May 9, 2010 at 6:07pm UTC
It's probably a compiler extension that returns the file descriptor.
sharanu008: Are you sure you're not supposed to compare to zero?
May 9, 2010 at 7:27pm UTC
Okay then. In that case, it looks like your file descriptor fetching function isn't working properly, because you're getting FILE* back out when you should be getting 1.
@helios: 0 is reserved by stdin.
-Albatross
May 10, 2010 at 7:46am UTC
The bottom line is you are using a non-standard member of fstream. Maybe you could tell us what you are trying to achieve?