如何将char *转换为File * [英] how to convert char* to File *

查看:130
本文介绍了如何将char *转换为File *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在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.

推荐答案


cn**@263.net 写道:

cn**@263.net wrote:



我在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?


cn ** @ 263.net 写道:



我在char *中有一个长字符串并且想要将它转换为文件*

fp。

有没有最好的方法可以不使用tmpfile?


谢谢。
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.



没有标准方法在数组顶部打一个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.


cn ** @ 263.net 写道:



我在char *中有一个长字符串,想要将其转换为文件*

fp。

有没有最好的方法可以不使用tmpfile?
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?



我认为你的意思是文件*,而不是文件*。


你是什么意思转换?您可以使用强制转换运算符将char *转换为FILE *

,但结果不会有意义。

您可以将字符串写入a文件,但那不是我称之为

的转换。你究竟想要完成什么?


-

Keith Thompson(The_Other_Keith) ks *** @ mib.org < 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 *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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