473,396 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Header File Problem

:chomp: Hey guys i have an address book that needs to work. I have a header file, but my program says missing header file. here is my code for the program:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include "addressbook.h"
  3. using namespace std;
  4.  
  5.  
  6. struct PERSON
  7. {
  8.     char fName[25];
  9.     char lName[25];
  10.     char email[25];
  11.  
  12. };
  13.  
  14. PERSON addresses[MAXADDRESS]:
  15. const int MAX_ADDRESSES = 25;
  16. int counter = 0;
  17. int counter2 = 0;
  18. PERSON addresses[MAX_ADDRESSES];
  19.  
  20. void addPerson(PERSON &p);
  21. void getPerson(PERSON &p);
  22.  
  23. int main()
  24. {
  25. PERSON pn, test;
  26. bool command;
  27. int selection;
  28.  
  29.     for(;;)
  30.     {
  31.  
  32.         cout << "1. Add person" << endl;
  33.         cout << "2. Get Person" << endl;
  34.         cout << "0. Exit" << endl;
  35.         cin >> selection;
  36.         switch(selection)
  37.         {
  38.  
  39.         case 1:
  40.             cout << "Enter your first Name, and last name" << endl;
  41.             cin >> pn.fName >> pn.lName;
  42.             cout << "Enter your Email Address" << endl;
  43.             cin >> pn.email;
  44.  
  45.             addPerson(pn);
  46.  
  47.             getPerson(test);
  48.         case 2 :
  49.             cout << test.fName << "  " << endl;
  50.             cout << test.lName << "\n " << endl;
  51.             cout << test.email << "\n\n" << endl;
  52.             return 0;
  53.         case 0:
  54.             exit(0);
  55.         }
  56.     }
  57. }
  58. void addPerson(PERSON &p)
  59. {
  60.     if(counter < MAX_ADDRESSES)
  61.         addresses[counter++] = p;
  62.     else
  63.         cout << "Address Book is Full.\n" << endl;
  64. }
  65.  
  66. void getPerson(PERSON &p)
  67. {
  68.     if(counter2 == 0)
  69.         counter2 = counter;
  70.     p = addresses[--counter];
  71.  
  72. }
  73.  
Header Code: My header is called "addressbook.h"
Expand|Select|Wrap|Line Numbers
  1. #ifndef double_H
  2. #define double_H
  3.  
  4.  
  5. class double
  6. {
  7. private:
  8. }
  9. public:
  10.     {
  11. void addPerson(PERSON &p)
  12. {
  13.     addPerson(pn);
  14.  
  15. }
  16. void getPerson(PERSON &p)
  17. {
  18.     getPerson(test);
  19. }
  20.  
  21.     }
  22.     PERSON addresses[MAXADDRESS]:
  23. const int MAX_ADDRESSES = 25;
  24. int counter = 0;
  25. int counter2 = 0;
  26. PERSON addresses[MAX_ADDRESSES];
  27. #endif
  28.  
WHY AM I GETTING THIS ERROR?
Oct 12 '07 #1
2 1287
oler1s
671 Expert 512MB
I assume the error you get is from your compiler, and it's something along the lines of not able to find addressbook.h . In the future, please post your errors verbatim. It is not a smart idea to paraphrase technical details. As you probably will get them wrong in your summary.

I would say, is addressbook.h located in the same folder as the source file that includes the header?
Oct 13 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
When you include:
Expand|Select|Wrap|Line Numbers
  1. #include <addressbook.h>
  2.  
you are telling the preporcessor that the header is located on a pre-defined path. Here you need to make a setting in your tool that defines what the path is. This setting if often call addtional include directories.

When you include:
Expand|Select|Wrap|Line Numbers
  1. #include "addressbook.h"
  2.  
you are telling the preprocessor that the header is located in your present working directory (PWD). Usually, this is the folder with your project files in it. If the header is not there, the search reverts to the case above that uses the angle brackets.
Oct 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
4
by: Andrew Ward | last post by:
Hi All, I was wondering if it is possible to use precompiled headers without having to include a <stdafx.h> or whatever in every source file. My problem is that I have a project that makes heavy...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
16
by: wdh3rd | last post by:
Hi everyone. I'm new to C and I have a few questions: I am making files for permutations and combinations. Files to be made are perm.c, perm.h, combo.c, and combo.h. Since both combinations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.