Header File Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clockworx05
    New Member
    • Sep 2007
    • 11

    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:

    Code:
    #include <iostream>
    #include "addressbook.h"
    using namespace std;
    
    
    struct PERSON
    {
    	char fName[25];
    	char lName[25];
    	char email[25];
    
    };
    
    PERSON addresses[MAXADDRESS]:
    const int MAX_ADDRESSES = 25;
    int counter = 0;
    int counter2 = 0;
    PERSON addresses[MAX_ADDRESSES];
    
    void addPerson(PERSON &p);
    void getPerson(PERSON &p);
    
    int main()
    {
    PERSON pn, test;
    bool command;
    int selection;
    
    	for(;;)
    	{
    
    		cout << "1. Add person" << endl;
    		cout << "2. Get Person" << endl;
    		cout << "0. Exit" << endl;
    		cin >> selection;
    		switch(selection)
    		{
    
    		case 1:
    			cout << "Enter your first Name, and last name" << endl;
    			cin >> pn.fName >> pn.lName;
    			cout << "Enter your Email Address" << endl;
    			cin >> pn.email;
    
    			addPerson(pn);
    
    			getPerson(test);
    		case 2 :
    			cout << test.fName << "  " << endl;
    			cout << test.lName << "\n " << endl;
    			cout << test.email << "\n\n" << endl;
    			return 0;
    		case 0:
    			exit(0);
    		}
    	}
    }
    void addPerson(PERSON &p)
    {
    	if(counter < MAX_ADDRESSES)
    		addresses[counter++] = p;
    	else
    		cout << "Address Book is Full.\n" << endl;
    }
    
    void getPerson(PERSON &p)
    {
    	if(counter2 == 0)
    		counter2 = counter;
    	p = addresses[--counter];
    	
    }
    Header Code: My header is called "addressboo k.h"
    Code:
    #ifndef double_H
    #define double_H
    
    
    class double
    {
    private:
    }
    public:
    	{
    void addPerson(PERSON &p)
    {
    	addPerson(pn);
    			
    }
    void getPerson(PERSON &p)
    {
    	getPerson(test);
    }
    
    	}
    	PERSON addresses[MAXADDRESS]:
    const int MAX_ADDRESSES = 25;
    int counter = 0;
    int counter2 = 0;
    PERSON addresses[MAX_ADDRESSES];
    #endif
    WHY AM I GETTING THIS ERROR?
  • oler1s
    Recognized Expert Contributor
    • Aug 2007
    • 671

    #2
    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?

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      When you include:
      [code=c]
      #include <addressbook. h>
      [/code]

      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:
      [code=c]
      #include "addressboo k.h"
      [/code]

      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.

      Comment

      Working...