using istream to read from named pipe
问题 Is it possible to read from named pipe (mkfifo) using c++ (stl) using a stream - thus not defining in advance char *buffer[MAX_SIZE] for the read operation? I want to read till the buffer ends and put the result into std::string . (Current method: bytes = read(fd, buffer, sizeof(buffer)); requires allocation some kind of buffer in advance.) 回答1: Named pipes created with mkfifo behave like regular files. Thus they can be accessed using std::ifstream and std::ofstream : #include <fstream>