问题描述
我最近在使用fputs时遇到了麻烦:在带有fputs的文本文件中打印一些字符串时,碰巧我得到了除AZ,az,0-9以外的其他字符(字符不属于字符串) 。我完全确定所有字符串都以空字符结尾。很遗憾,由于我没有亲自测试该程序,因此我无法提供更多信息,这就是我收到的反馈。但是在我将fputs替换为fprintf之后,它可以正常工作。
I've been having trouble with fputs lately: when printing some strings in a text file with fputs, it happens I get other characters than A-Z, a-z, 0-9 in (chars that aren't part of the string). I made absolutely sure the strings all end with the null character. Unfortunately I can't give you more information, since I did not personally test the program, that was the feedback I received. But after I replaced fputs with fprintf it worked properly.
所以我的问题是:fputs有点危险吗?
So my question is: is fputs sort of dangerous? Have you ever had trouble with it?
推荐答案
fputs
不是天生的吗?危险的。当然,没有示例代码,很难说是什么原因导致了您所看到的问题。
fputs
is not inherently dangerous. Of course without example code its hard to say what was causing the problem you were seeing.
这篇关于fputs / puts危险(以C表示)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!