2

I have the descriptor of a standard output device (STD_OUTPUT_HANDLE). Can I use it to create an object ostream ?

This descriptor for the console

HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)
  • Not sure if POSIX is correct. But there is http://stackoverflow.com/questions/475853/can-i-use-createfile-but-force-the-handle-into-a-stdofstream – Phil M Apr 29 '17 at 21:55
  • @PhilM And what if it's not a file, but a console? – Yevhenii Nadtochii Apr 29 '17 at 22:46
  • I don't know; they are both HANDLEs, so there's at least a small chance it might work. I'm curious to know, so if either of the two links works (or doesn't), comment back. – Phil M Apr 29 '17 at 23:15
  • Despite the fact that it is a duplicate anyway, please take two second to think about using the correct tags fpr your questions. There is no such thing as an ostream in C. – Gerhardh Apr 30 '17 at 00:42
  • Note that a handle is not the same thing as a descriptor. You can convert a handle to a descriptor using _open_osfhandle. – Harry Johnston Apr 30 '17 at 00:43

0 Answers0