문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top