What does "f" stand for in C standard library function names?
The leading f refers to the type that function operates on:
fgets
: usegets
on aFILE *
handle instead of juststdin
fopen
: open a file, and return it as aFILE *
(instead of a file descriptor which the originalopen
does)
The trailing f means that it uses a formatting string:
printf
: print out according to the format specifierscanf
: read in according to the format
And combined, you get things like:
fprintf
: print out to a particularFILE *
according to the format specifier
When you consider things like the math.h
functions, then the trailing f designates that the particular function operates on operands of type float
like so:
powf
: take the exponent offloat
spowl
: take the exponent oflong double
s
Your question in general is too general but I can explain a few examples.
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.
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.