'Creating fstream object from a FILE* pointer

The well known way of creating an fstream object is:

ifstream fobj("myfile.txt");

ie. using a filename.

But I want to create an ifstream object using a file descriptor.

Reason: I want to execute a command using _popen(). _popen() returns the output as a FILE*. So there is a FILE* pointer involved but no filename.



Solution 1:[1]

You can try QTextStream.

See in https://doc.qt.io/qt-6/qtextstream.html#QTextStream-2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 untitled