converting file descriptor to FILE pointer

Discussion in 'General Computer Support' started by HelloC++, May 24, 2007.

  1. HelloC++

    HelloC++

    Joined:
    May 24, 2007
    Messages:
    1
    Likes Received:
    0
    I have a file descriptor, is there any way I can convert it to FILE* or ifstream* on windows.

    Code:
    HANDLE hFile;
    hFile = CreateFile(filename, // open One.txt
    	GENERIC_READ, // open for reading
    	0, // do not share
    	NULL, // no security
    	OPEN_EXISTING, // existing file only
    	FILE_ATTRIBUTE_NORMAL, // normal file
    	NULL); // no attr. template
    
    int fd = (int)hFile;
    FILE* pFile = fd; ///how to convert fd to FILE*  ?????????
    or
    ifstream ifs = fd;///how to convert fd to ifstream ???????????????
    Thanks
     
    HelloC++, May 24, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.