Friday, May 9, 2008

Use of library functions

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.

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.

0 comments:

Copyright

Copyright © 2008 C Tutorial, All rights are reserved