You are here:

C/program to include c function in other program

Advertisement


Question
sir,suppose i written a program for factorial...with "fact.c" ..now i want to include this program on other program say("myprogram.c").its like including headerfile in c..
please help me in this regard..

Answer
Hai Dear Mr Venkat !


  Of course its simple , just follow the instructions.( assuming that you are Turbo C/C++ user )

Create a file that contains all the re-usable functions , say fact() and so on and save with a .h extension say "sample.h"
1. just copy the file into the INCLUDE Directory .
(0r)

Open the Option Menu -> Directories -> Include Directories ,

Include Directory text box will contain some Path name ,

eg if it contain c:\tc\INCLUDE

Then just place a ; at the end and enter  path name of your header file "sample.h" assuming "sample.h" is placed in c:\tc\bin

Then the Entry in Option Menu -> Directories -> Include Directories

Will be like this c:\tc\INCLUDE;c:\tc\bin

Then open a new file say myprogram.c and use your own header file "sample.h" just like other header files

Eg;

#include<stdio.h>
#include<sample.h>


I Request you to kindly get back to me in case of issue !

Thanks and Regards !
Prince M. Premnath

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise


I'm sure that I can solve any doubts in Turbo C ,Graphics Programing ,Mouse, Hardware Programming ,File System ,Interrupts, BIOS handling , TSR Programming , General Concepts in C Language, handling inline Assembly statements

Experience

Research over 6+ Years

Organizations
CG-VAK Softwares and Exports Limited

Education/Credentials
Masters in Computer Applications

©2012 About.com, a part of The New York Times Company. All rights reserved.