Answer Posted / raje
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();
}
| Is This Answer Correct ? | 10 Yes | 12 No |
Post New Answer View All Answers
Can we initialize extern variable in c?
What is a pointer in c plus plus?
what is the format specifier for printing a pointer value?
Without Computer networks, Computers will be half the use. Comment.
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
what do you mean by inline function in C?
What is the difference between array and linked list in c?
Why c is a procedural language?
What is a void pointer? When is a void pointer used?
What is the purpose of type declarations?
What is the advantage of using #define to declare a constant?
what is the height of tree if leaf node is at level 3. please explain
Difference between strcpy() and memcpy() function?
Explain what happens if you free a pointer twice?