hi i m mohan sahu.i m using turbo c( borland compiler) and working with windows xp. i have one header file say myheader.h having only declarations of all functions and one myfunc.c file having only definitions of all function without main and i m including header file with #include "myheader.h" in this program.when i m using this header file in other program say func.c where i m including header by #include "myheader.h" but compiler is showing the error "unable to include myheader.h" .can anyone suggest me how to compile and link these files so that it will work properly.

One possible reason can be that 'func.c' is not in the same directory/folder as 'myheader.h' and if this is the case then either you can put the 'myheader.h' in the same directory/folder as 'func.c'

OR

You can put the 'myheader.h' in some standard path where your turbo c compiler searches for standard .h files(but in this case you have to change the line from

#include "myheader.h"

to

#include <myheader.h>

Hope it helps....

I have a small example how linking is to be done.
Suppose i have two program named imp.c and imp1.c
imp.c contains

void arr()
{
printf("hello ajay");
}

imp1.c contains

void art()
{
printf("My name is ajay");

}

then linking of above two programs with the program imp3.c
is done as

#include<stdio.h>
#include<conio.h>
#include<g:\tc\bin\imp.cpp>
#include<g:\tc\bin\imp1.cpp>
int main(void)
{
clrscr();
printf("this is the imp one:");
art();
arr();
return(0);
}
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.