• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Header Files

While I don't doubt that this question has been asked X times, I cannot search for an answer, and Google is of absolutely no help on this one.

How do you create header files? My book says to create one that contains four function prototypes (which I know how to do), but the book doesn't say anywhere how to create them (.h files). I'm using Visual C++.

Thanks in advance,
1 Solution
There's no magic.  Just create a new text file.  Something like  (File menu -> New File).  I'm using VS.NET now so can't remember the menus from Visual C++ 6.  In any case, just create a new blank file, type in your header info and then save it with a .h extension.

Most header files look something like this:


// Function prototypes go here.
int myFunction(int x) ;
int myOtherFunction(char* c) ;


The "MYHEADERFILE" stuff ensures that the header file is only loaded once (so you can write #include "myheader.h" twice in the same file and it's ok).

steinway_artistAuthor Commented:
Thank you. :)
In Visual C++ 6.0, you can do it this way:

Open the File menu.

Select New....

Select the Files tab.

Select C/C++ Header File.

Enter a file name.

There are other controls in the dialog where you can choose to include the file in a project or not, and specify in what directory it should be created.

And Doug was right:  it's just a text file.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now