linking of .c and .h files

Reply

Join Date: Jan 2009
Posts: 4
Reputation: mohan_198505 is an unknown quantity at this point 
Solved Threads: 0
mohan_198505 mohan_198505 is offline Offline
Newbie Poster

linking of .c and .h files

 
0
  #1
Jan 22nd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 44
Reputation: me_ansh is an unknown quantity at this point 
Solved Threads: 5
me_ansh me_ansh is offline Offline
Light Poster

Re: linking of .c and .h files

 
0
  #2
Jan 22nd, 2009
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
  1. #include "myheader.h"

to

  1. #include <myheader.h>

Hope it helps....
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: linking of .c and .h files

 
0
  #3
Jan 23rd, 2009
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
  1. void arr()
  2. {
  3. printf("hello ajay");
  4. }
imp1.c contains
  1. void art()
  2. {
  3. printf("My name is ajay");
  4.  
  5. }
then linking of above two programs with the program imp3.c
is done as
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<g:\tc\bin\imp.cpp>
  4. #include<g:\tc\bin\imp1.cpp>
  5. int main(void)
  6. {
  7. clrscr();
  8. printf("this is the imp one:");
  9. art();
  10. arr();
  11. return(0);
  12. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: linking of .c and .h files

 
0
  #4
Jan 24th, 2009
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC