954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Headers?

I am using VC++...

I need to know how to add a header to the Application,
Can someone Joe, or anyone else Give me Step By step on how to do it...

Say I had a header called Bob.h

and I wanted to add it to my application Tauren

That needed it #include "b.h"

How would I add the Bob header to the application Tauren

If you dont understand what I said post...

Rember Step-By-Step I Am a noob you know!

Tauren
Junior Poster
108 posts since Oct 2006
Reputation Points: 9
Solved Threads: 0
 

Copy the header file to the same directory that contains the project you intend to use it in. Then wherever it is needed, simply insert

#include "whatever.h"



And it should work.

You can also use working directories (. and ..) to reference directories in your hard drive, although it's generally a bad idea to keep headers in some arbitrary folder on your hard disk if they are user-created.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

Ok got it to work but now its asking me to find somewhere to excute it

Tauren
Junior Poster
108 posts since Oct 2006
Reputation Points: 9
Solved Threads: 0
 
Ok got it to work but now its asking me to find somewhere to excute it


Huh? Could you post the exact error messages please?

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

Anthoer question....

If I wanna make a A header to say u would use it for the function

login to the game and then tell my server u did that would I have to make that header?
Actually how do u even make headerS?

Tauren
Junior Poster
108 posts since Oct 2006
Reputation Points: 9
Solved Threads: 0
 
Anthoer question.... If I wanna make a A header to say u would use it for the function login to the game and then tell my server u did that would I have to make that header? Actually how do u even make headerS?


Perhaps you should better learn what a header actually is. http://www.cs.cf.ac.uk/Dave/C/node35.html

Basically you use it to declare functions and let the compiler know that they exist. That way you can call the functions in other files where the function isn't currently defined.

One trick with header files to avoid multiple inclusion errors is to encase the code inside preprocessor directives:

#ifndef MYHEADERFILE_H
#define MYHEADERFILE_H

// header file goes here...

#endif


Basically you can replace MYHEADERFILE_H with anything you want, as long as it's unique and isn't used anywhere else in the program.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

u know how in games for the admin commands you have like / or .(command)
would i have to do like if .wave do animation.wave?

Tauren
Junior Poster
108 posts since Oct 2006
Reputation Points: 9
Solved Threads: 0
 

So if you press .help in the c++ game it would say What do u need and when u do .kick it would tell you to type in a name when u type in .kick it kicks the player and says player kicked

Tauren
Junior Poster
108 posts since Oct 2006
Reputation Points: 9
Solved Threads: 0
 

I use Code::Blocks not VC++ but a header file (.h) contains prototypes, inline functions, macros, constants (i.e #define) and certainttypes of variables. When the IDE (i.e VC++) searches for include files it is usually in a default directory containing most, if not all, include files. If you have a corresponding (.cpp or .c++) file, it'd either be in the same directory or another - which varies among IDE configuration. Some IDE's and compilers allow you to transverse using a syntax such as (<../../header_file.h>). So a SUGGESTION would be to put your header files in the default directory and includ then via there. Also, to prevent inclusion, make sure you use the conditional preprossessor directives (i.e #ifndef HEADER_H etc...). If you decide to create and implement your own library(s) make sure it is under its own namespace. Last, you can always check out the HELP documentation for VC++ if all else fails; Microsoft usually has an exhaustive amount of documentation and even some tutorials for there products. Good luck my fellow Daniweb friend.

LamaBot

Lazaro Claiborn
Junior Poster
171 posts since Jan 2007
Reputation Points: 11
Solved Threads: 13
 
Tauren
Junior Poster
108 posts since Oct 2006
Reputation Points: 9
Solved Threads: 0
 
u know how in games for the admin commands you have like / or .(command) would i have to do like if .wave do animation.wave?
So if you press .help in the c++ game it would say What do u need and when u do .kick it would tell you to type in a name when u type in .kick it kicks the player and says player kicked


You're getting too far ahead of yourself. You'll know how to do these things once you understand and learn the base and underlying concepts.

Also, those things you mentioned have nothing or very little to do with header files. Header files are basically a feature to allow code splitting into multiple files a bit easier. The actual features that you implement don't have much to do with how you split them up.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You