open_memstream等效为MSVC [英] Equivalent of open_memstream for MSVC

查看:376
本文介绍了open_memstream等效为MSVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用* open_memstream *在我的图书馆,但我想这个端口图书馆MSVC。似乎没有同等功能可用,但有足够的类似的东西?

I am using *open_memstream* in a library of mine, but I would like to port this library to MSVC. It seems there are no equivalent function available, but is there something similar enough?

什么* open_memstream *确实是它需要一个char **目的地和尺寸,并返回该你许多写入时,数据被存储在动态分配的缓冲液(来自焦炭**论点访问)FILE *。当关闭该文件的字符**包含已写入流中的数据。这使得一个简单的方法来构建庞大而复杂的字符串流。

What *open_memstream* does is it takes a char** destination and size and returns a FILE* which you many write to, the data is stored in a dynamically allocated buffer (accessible from the char** argument). When closing the FILE the char** contains the data that was written to the stream. This makes an easy way to construct large and complex string streams.

虽然可以读取和从memstream我只写它追求的。

While it is possible to both read and seek from the memstream I only write to it.

有没有一种方法来打开MSVC一个类似的内存文件流?此外,这是纯C,没有C ++。

Is there a way to open a similar memory FILE stream in MSVC? Also, this is pure C, no C++.

推荐答案

在Windows类似的功能会了CreateStreamOnHGlobal()。然而,这与的IStream COM接口工作,它不是一个简易替换备案。您可能要采取偷看在Cygwin的源头code,看看他们做了什么。

A similar function on Windows would be CreateStreamOnHGlobal(). That however works with the IStream COM interface, it isn't a drop-in replacement for FILE. You might want to take a peek at the Cygwin source code to see what they did.

这篇关于open_memstream等效为MSVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆