问题描述
我在char *中有一个很长的字符串,想把它转换为文件*
fp。
有吗没有使用tmpfile的最佳方法吗?
谢谢。
wy。
Hi,
I have a long string in char * and want to convert it to a File *
fp.
Is there any best way to do it without using tmpfile?
Thanks.
wy.
推荐答案
这个问题对其他人有意义吗?您是否打算打开
文件?
Does this question make sense to anyone else? Are you trying to open a
file?
没有标准方法在数组顶部打一个FILE *接口。
(某些系统提供了扩展) 。
您可以将数组的内容写入文件并打开
但是 - 因为您提示您已经发现了您的引用
''tmpfile''。
然后再说明你真正需要的是什么。
There is no standard way to slap a FILE* interface on top of an array.
(some systems provide an extension for that).
You can write the content of your array to a file and open that
though - as you hint you have discovered with your references to
''tmpfile''.
Then again it isn''t that clear what you really need.
我认为你的意思是文件*,而不是文件*。
你是什么意思转换?您可以使用强制转换运算符将char *转换为FILE *
,但结果不会有意义。
您可以将字符串写入a文件,但那不是我称之为
的转换。你究竟想要完成什么?
-
Keith Thompson(The_Other_Keith)< http://www.ghoti.net/~kst>
圣地亚哥超级计算机中心< *< http:// users.sdsc.edu/~kst>
我们必须做点什么。这是事情。因此,我们必须这样做。
I presume you mean FILE*, not File*.
What do you mean by "convert"? You can convert a char* to a FILE*
with a cast operator, but the result isn''t going to be meaningful.
You can write a string to a file, but that''s not what I''d call a
conversion. What exactly are you trying to accomplish?
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
这篇关于如何将char *转换为File *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!