I have a file name fun.c contain the fuction to add two number (addnum(a,b)).Now I create another file name callfunc.c.Here I want to call the function (addnum(a,b)) from the file fun.c. How can I do that?.

Recommended Answers

All 4 Replies

I think that you have to make a header file containing that function.

I would not quote me on this.

You might want to find one of the more advanced C users.

Hope this helps!

commented: How can it possibly help if you don't know the answer? -2

I have a file name fun.c contain the fuction to add two number (addnum(a,b)).Now I create another file name callfunc.c.Here I want to call the function (addnum(a,b)) from the file fun.c. How can I do that?.

Create a header file fun.h with a prototype of the function.
Add #include "fun.h" to the beginning of callfunc.c
Compile the two C files together.

Do you realize that in English, when you end a sentence with a . you're supposed to add a space or two so it's easy to understand what you write? That goes for !?, too.

Create the header file func.n and include all the function declarations in this file.
In the other C file, use extern followed by the name of the function.

commented: sorry. no. +7
commented: I think jep meant to give you the orange!! -1

Create the header file func.n and include all the function declarations in this file.
In the other C file, use extern followed by the name of the function.

no, that is entirely incorrect. please do not post wrong answers after someone has already correctly answered the question.

jgehlot, what Walt posted is correct, just do what he said

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.