how to create .h header files for .c files? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

how to create .h header files for .c files?

jennafjennaf Posts: 1Member

Hi, I have a program that I just wrote, but really its just a program that will be used by a larger program that I am working on. The larger program will run some functions in the small program, accessing some of its global arrays/variables to extract information.

I never knew how to create a header file so that this large program can include it. I think what i use to do was just "include small_prog.c" but I know thats not correct.

So how do we go about creating a header file?

The small program basically has:
-1 global array variable pointer
-3-4 int variables
- includes math.h, time.h, stdio.h, stdlib.h ctype.h
- #define MAX_ARRAY_SIZE 100
- a main function (only used if your running the file on its own)
- several functions that perform instructions to modify the above variables.

an example of this could be:


#define MAX_ARRAY_LENGTH 100
int* matrix_array;
int dimension=0;
int matrix_mode=0;
int x = 0;

void func1 (int x);
float func2 (float y);
int func3 (char a);

int main(int argc, char* argv[])
and so on

So I want to include this small program in a large program, by refering to a .h file. but what do i write in the h file?


Sign In or Register to comment.