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
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What are the general description for loop statement and available loop types in c?
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
Explain how can you restore a redirected standard stream?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
Can one function call another?
Why do we use static in c?
What is typedf?
What is queue in c?
What is the 'named constructor idiom'?
What is the benefit of using an enum rather than a #define constant?
What is meant by realloc()?
How can you invoke another program from within a C program?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
How do I swap bytes?