Explain giving an example.
Solution 17:
The function that is to be added to the library is first compiled. Then it is added to the
library using a TLIB utility named tlib.exe (a facility in turbo c). After adding the function, the linker
will automatically link it with your program code as it does with inbuilt functions of C. Consider an
example of a factorial function as follows:
int fact(int n)
{
int i, f = 1;
for (i=1; i<=n; i++)
f = f *i;
return (f);
}
Save this program in some file—say, facto.c
Now compile this file using the ctrl+F9 key. This creates a “facto.obj” file having object code.
From the DOS prompt, add the function to the library by using the command:
Do'stlaringiz bilan baham: |