Header Files

Posted on 2003-03-28
Medium Priority
Last Modified: 2010-04-01
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,
Question by:steinway_artist
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 28

Accepted Solution

dpearson earned 60 total points
ID: 8228825
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).


Author Comment

ID: 8228935
Thank you. :)
LVL 15

Expert Comment

ID: 8228948
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question