Getting "Cannot convert int to FILE *" error

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


What is fd() supposed to do? It doesn't show up in the standard library reference...

http://cplusplus.com/reference/iostream/ofstream/rdbuf/
http://cplusplus.com/reference/iostream/filebuf/

-Albatross
It's probably a compiler extension that returns the file descriptor.

sharanu008: Are you sure you're not supposed to compare to zero?
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
The bottom line is you are using a non-standard member of fstream. Maybe you could tell us what you are trying to achieve?
Topic archived. No new replies allowed.