HOW CAN ADD OUR FUNCTION IN LIBRARY.

Answer Posted / vignesh1988i

it's simple.....

just have ur function definition in one Cpp or C file.....ie save it as .cpp or .C file....
then include the file as #include "program.c"
and then wherever you need call that functionin an another program...
for example:
let me add my own ADDITION function in my library.....

this is my first file stored in .C....
int add(int a,int b)
{
int c;
c=a+b;
return c;
}
the file name for the above is add.c

then am opening my main program file in .c mode ....
#include<stdio.h>
#include<conio.h>
#include"add.c"
void main()
{
int a,b,c;
scanf("%d%d",&a,&b);
c=add(a,b);
printf("\n the added sum is :%d",c);
getch();
}



thank u

Is This Answer Correct ?    40 Yes 29 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there a way to compare two structure variables?

619


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

644


What is structure in c definition?

577


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

14971


What is difference between arrays and pointers?

584






Where can I get an ansi-compatible lint?

646


What are 3 types of structures?

596


What does %c do in c?

589


What does %d do in c?

547


What is hashing in c language?

618


Which is an example of a structural homology?

790


Explain what is meant by high-order and low-order bytes?

637


Why do we need arrays in c?

589


What is the scope of global variable in c?

560


Explain threaded binary trees?

684