Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a Headly File 1

Status
Not open for further replies.

Lauro

Programmer
Jul 29, 2001
10
BR
Hi all!!!


Well,

I'd like to know how to create headly files in C language.
Someone can I help me?
 
Here is the sample. be shure to compile both .c files together , and that the three files are in the same dir.


Code:
//file: myfunc.c
#include "myfunc.h"

long myadd(int a,int b){

  return a+b;
}

//end file myfunc.c
-------------------------------

//file myfunc.h

long myadd(int a,int b);

//end file myfunc.h


-------------------------

//file myfndemo.c

#include <stdio.h>
#include &quot;myfunc.h&quot;

void main(void){
  
  long result;


  result = myadd(5,5);

  printf(&quot;%ld\n&quot;,result);

}

//end file myfndemo.c
 
don't forget about eliminating conflicts. All edclarations must be defined only once:

#if !defined(__MYFUNC_H)
/*if is already defined, code till #endif is ignored*/
#define __MYFUNC_H
long myadd(int a,int b);
#endif

So you will avoid doulbe insertion. For example you include this file and other file which include also this one.
John Fill
1c.bmp


ivfmd@mail.md
 
yes, you'r right, sorry for that ..........i typed online .... you know .... its just a practical sample
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top