How to Access File Descriptor of Open File
-
29-09-2019 - |
문제
Is there any way to access the file descriptor of a file opened in c++? So ...
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream inputFile( "file.txt",ios::in );
cout << inputFile.fileDesc << endl;//made up call
return 0;
}
The question is, does something like fileDesc exist for ifstreams? If not how would I go about doing this?
해결책
If you're trying to get to the FILE* from the stream then the answer is basically "you can't" as stated by more enlightened people than me here.
다른 팁
Take a look at open():
The open function creates and returns a new file descriptor for the file named by filename.
제휴하지 않습니다 StackOverflow