scanf()的和与fgets之间的差异() [英] Difference between scanf() and fgets()
本文介绍了scanf()的和与fgets之间的差异()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道的是什么与fgets之间的差值()
和 scanf()的
。我使用C作为我的平台。
I want to know what is the difference between fgets()
and scanf()
. I am using C as my platform.
推荐答案
有多重分歧。两个重要的是:
There are multiple differences. Two crucial ones are:
-
与fgets()
可从任何打开的文件中读取,但scanf()的
只能读取标准输入。 -
与fgets()
读一行文字从文件;scanf()的
可用于如此还要处理从字符串转换为内置的数字类型。
fgets()
can read from any open file, butscanf()
only reads standard input.fgets()
reads 'a line of text' from a file;scanf()
can be used for that but also handles conversions from string to built in numeric types.
很多人会用与fgets()
来读取一行数据,然后使用的sscanf()
来剖析吧。
Many people will use fgets()
to read a line of data and then use sscanf()
to dissect it.
这篇关于scanf()的和与fgets之间的差异()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文