fgets返回“作为最后一个字符 [英] fgets returning " as last character
本文介绍了fgets返回“作为最后一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用fgets从文件中获取字符串.
Aint fgets应该返回一个以空字符结尾的字符串,相反,我得到的字符串中带有作为我的最后一个字符."
Hi,
Im using fgets to fetch a string form my file.
Aint fgets supposed to return a null terminated string, instead i am getting a string with " as my last character.
推荐答案
将其不是,实际上是" \ n''
必须检查并替换为"\ 0".
Sry its not " , its actually ''\n''
had to check and replace it by ''\0''.
这篇关于fgets返回“作为最后一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文