In "printf" and "scanf", the "f" at the end means "formatted input/output". This is because these functions perform format conversion: they can handle integers, floats, characters, strings, and pointers, and they know how to convert between data types and character data accordingly. This contrasts with, say, getchar
, which only has the ability to fetch one character at a time, and cannot interpret input data as numeric values or pointers or anything like that. It is an unformatted I/O function.
In "fflush", "fopen", "fread", "fwrite", and so on, the "f" at the beginning means "file". Such functions expect a FILE*
as an argument and operate on the corresponding stream. In some cases, this distinguishes them from functions that assume standard input or standard output: getchar
versus fgetc
, gets
versus fgets
. In other cases it distinguishes them from Unix functions that operate on file descriptors (which are integers) rather than C FILE*
streams: fopen
versus open
, fwrite
versus write
, and so on. Note that this can be combined with the suffix "f": fprintf
means "formatted output to a FILE*
".
Finally, all the math functions in math.h
come in three versions: one for floats, one for doubles, and one for long doubles. Hence, for example, cosf
, cos
, cosl
. The "f" in this case means the argument is of type float
, and the suffixes are needed because functions cannot be overloaded in C (but see type-generic expressions, introduced in C11).
As a special case, the "f" in fabs
, which operates on floating point types, distinguishes it from abs
, which operates on integer types.