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

What is calloc malloc realloc in c?

579


What is LINKED LIST? How can you access the last element in a linked list?

621


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3167


What does emoji p mean?

589


What is return in c programming?

503






What is the meaning of 2d in c?

598


How do you do dynamic memory allocation in C applications?

618


Explain b+ tree?

612


explain how do you use macro?

655


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

705


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5453


Explain what is the benefit of using enum to declare a constant?

576


What is string function c?

558


Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

642


Difference between exit() and _exit() function?

645