I've just started learning C++ using C++ Primer 5th edition.

When i try to build the following program:

#include <iostream>
#include "Sales_item.h"

int main()
sales_item book;
std::cin >> book;
std::cout << book << std::endl;
return 0;


I get stuck. #include "Sales_item.h" seem's to be the problem, In the book it says to put it in my "working directory", Where exactly is my working directory? I've put this file in each folder where where i compile my program's to i.e. program name-> bin etc... and the only error i have is:

fatal error: Sales_item.h: No such file or directory
closed account (3qX21hU5)
You are correct it is not able to find the Sales_item.h header file. Your working directory is where your main.cpp (Or whatever you called it) file is. Another way to include it without moving the file is to open up your project settings and tell the compiler where to look for include files.

For visual studio you can do project options then under C++ and general (I think) you will see a thing that says additional include directories or something along those lines. Double click in the box and then you can browse to where your Sale_item.h file is and include the folder it is in.
Last edited on
I'm currently using Codeblocks/Mingw.
After another search session i'm still no nearer to resolving this.
Topic archived. No new replies allowed.