custom FILE type in C/C++ -


Is it possible to create my own custom stream in FILE (stdio.h) in C / C ++ Can be done with example?

If your "custom stream" is nothing, you handle file descriptor or file, then you are destined Out of the FILE type is implementation-defined, so there is no standard way to associate the other with one.

If you can get the C file descriptor, then whatever you are trying to write, you can change it to a FILE * . It is not standard C or C ++, but it is provided by Pausix. On Windows, it's spelling.

If you are using Windows and you have handle , you can use it to associate the file descriptor with it, and then _fdopen From .

Are you really tied to fputs ? If not, replace it with the use of a C ++ IOStream. You can then provide your descendant of std :: basic_streambuf , wrap it in std :: ostream , and use standard C ++ I / O on it Please.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -