Use of Library Functions

To use a function, ensure that you have made the required #includes in your C file. Then the function can be called as though you had defined it yourself.

It is important to ensure that your arguments have the expected types, otherwise the function will probably produce strange results. lint is quite good at checking such things.

Some libraries require extra options before the compiler can support their use. For example, to compile a program including functions from the math.h library the command might be


  cc mathprog.c -o mathprog -lm

The final -lm is an instruction to link the maths library with the program. The manual page for each function will usually inform you if any special compiler flags are required.


  Go to finding info     Go to Index               Go to some functions