Question:
How to add user-defined functions to the library?
Yogesh
2012-04-22 10:38:14 UTC
I want to add user-defined function [factorial()] to the library [maths.lib].I m using TURBO C.Pls tell me the complete procedure?
Four answers:
Erika
2016-10-23 04:35:15 UTC
you are able to no longer upload to the c application language till you have source code for a compiler after which you may very possibly purely make alterations that influence how your very own code is compiled. of direction you are able to exchange your very own code to handle blunders checking, yet that falls under consumer defined workouts, applications, coding however. you will have already got given me terrific answer approximately your pointer question. To proceed stupid analogies. C grants a cat yet no kitty clutter.
pramod
2012-04-22 23:24:41 UTC
Note: Function is one of the important topics in C and C++. The source code for this Module is: C/C++ functions source codes and the lab worksheets for your practice: Function lab worksheet 1, lab worksheet 2, lab worksheet 3 and lab worksheet 4.





The C and C++ skills that supposed to be acquired:







Able to understand and use function.

Able to create user defined functions.

Able to understand Structured Programming.

Able to understand and use macro.

Able to appreciate the recursive function.

Able to find predefined/built-in standard and non-standard functions resources.

Able to understand and use predefined/built-in standard and non-standard functions.

Able to understand and use the variadic functions.





4.1 Some Basic Definition







Most computer programs that solve real-world problem are large, containing thousand to million lines of codes and developed by a team of programmers.



The best way to develop and maintain large programs is to construct them from smaller pieces or modules, each of which is more manageable than the original program.



These smaller pieces are called functions. In C++ you will be introduced to Class, another type smaller pieces construct.



The function and class are reusable. So in C / C++ programs you will encounter and use a lot of functions. There are standard (normally called library) such as maintained by ANSI C / ANSI C++, ISO/IEC C, ISO/IEC C++ and GNU’s glibc or other non-standard functions (user defined or vendors specific or implementations or platforms specific).



If you have noticed, in the previous Modules, you have been introduced with many functions, including the main(). main() itself is a function but with a program execution point.



Functions are very important construct that marks the structured or procedural programming approach.



In general terms or in other programming languages, functions may be called procedures or routines and in object oriented programming, methods may be used interchangeably with functions.



Some definition: A function is a named, independent section of C / C++ code that performs a specific task and optionally returns a value to the calling program.



So, in a program, there are many calling function (caller) and called functions (normally called callee).



There are basically two categories of function:



Predefined functions - available in the C / C++ standard library such as stdio.h, math.h, string.h etc. These predefined functions also depend on the standard that you use such as ANSI C, ANSI C++, ISO/IEC C, Single UNIX Specification, glibc (GNU), Microsoft C etc. but the functions name and their functionalities typically similar. You have to check your compiler documentation which standard that they comply to.



User-defined functions – functions that the programmers create for specialized tasks such as graphic and multimedia libraries, implementation extensions or dependent etc. This is non-standard functions normally provided in the non-standard libraries.







You will encounter a lot of the predefined functions when you proceed from Module to Module in this Tutorial. Here we will try to concentrate on the user-defined functions (also apply to predefined function), which basically having the following characteristics:



A function is named with unique name - By using the name, the program can execute the statements contained in the function, a process known as calling the function. A function can be called from within another function.



A function performs a specific task - Task is a discrete job that the program must perform as part of its overall operation, such as sending a line of text to the printer, sorting an array into numerical order, or calculating a cube root, etc.



A function is independent - A function can perform its task without interference from or interfering with other parts of the program. The main program, main() also a function but with an



A function may receive values from the calling program (caller) - Calling program can pass values to function for processing whether directly or indirectly (by reference).



A function may return a value to the calling program - When the program calls a function, the statements it contains are executed. These statements may pass something back to the calling program.
?
2012-04-22 21:20:55 UTC
You can create your own library. Dont meddle with standard libraries.



In Unix, to create library first you compile files and create object files. Join them using ar command.



Read:

Linux Programming Tools Unveiled, NB Venkateswarlu, BS Pub, Hyderabad
jplatt39
2012-04-22 11:25:27 UTC
Don't. Seriously. If you have cpp and h files then compile them -- at least to object files, then use tlib to create a NEW library. Don't mess with the maths.lib file AT ALL. Clear?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...