"f"代表什么?在C标准库函数名称中代表? [英] What does "f" stand for in C standard library function names?
问题描述
f
在C标准库函数的名称中代表什么?我注意到许多函数的名称中都带有f
,这对我来说真的没有意义.
What does f
stand for in the name of C standard library functions? I have noticed that a lot of functions have an f
in their name, and this does not really make sense to me.
例如:fgets
,fopen
,printf
,scanf
,sqrtf
等.
推荐答案
您的问题总体而言过于笼统,但我可以解释一些示例.
Your question in general is too general but I can explain a few examples.
-
fgets
,fclose
,… — "f"代表文件".与POSIX函数一样,这些函数接受或返回FILE *
指针而不是文件号. -
printf
,fprintf
,sinf
,float(与double
替代项区分开).请注意,这与在1.5f
中加f
的浮点字面量后缀非常吻合.- 最后,作为重复数据删除器要点,其中有一些名称,例如
free
,setbuf
(设置缓冲区"),其中的"f"只是自然语言字符.
fgets
,fopen
,fclose
, … — The "f" stands for "file". These functions accept or return aFILE *
pointer as opposed to a file number as the POSIX functions do.printf
,scanf
, … — The "f" stands for "formatted". These functions accept a format string.fprintf
,fscanf
— This is a combination of the above two.sinf
,cosf
, … — The "f" stands forfloat
(to distinguish from thedouble
alternatives). Note that this fits quite nicely with suffixing floating point literals with anf
as in1.5f
.- Finally, as Deduplicator points out, there are some names such as
free
,floor
orsetbuf
("set buffer") where the "f" simply appears as a natural language character.
在名称中使用带单个字母的前缀或后缀来表示参数类型的传统是C中的必要条件,由于重载,它已在C ++中过时.实际上,在C ++中,重载是由编译器通过称为名称修改.
The tradition of pre- or suffixing names with single letters that indicate the type of the arguments is a necessity in C that has become obsolete in C++ thanks to overloading. Actually, overloading in C++ works by the compiler automatically adding those suffixes again under the hood to the generated symbols by a process called name mangling.
这篇关于"f"代表什么?在C标准库函数名称中代表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!