Need Help Finding Simple Error

I'm self-studying Bjarne Stroustrup's book "Programming: Principles and Practice Using C++" and I'm stuck on the first drill. He provides code for your to enter in. The code is below.

I downloaded the std_lib_facilities header file from his site and put it two directories up thus using ../../ in the header. I'm not sure why it's not compiling.


1
2
3
4
5
6
7
8

#include "../../std_lib_facilities.h"
int main()		// C++ programs start by executing the function main
{
	cout << "Hello, World!\n";	// output "Hello, World!"
	keep_window_open();			//wait for a character to be entered
	return 0;
}


1>c:...fatal error C1083: Cannot open include file: '../std_lib_facilities.h': No such file or directory
Last edited on
> put it two directories up thus using ../../ in the header.

If you did that, you need to write: #include "../../std_lib_facilities.h"

Or simpler, copy std_lib_facilities.h to the directory containing your program (main.cpp), and write
#include "std_lib_facilities.h"
http://www.linuxquestions.org/questions/linux-newbie-8/what-is-std_lib_facilities-h-716280/

GO through the above link it might be useful.I think you must have save to a wrong folder.

If you really want to print "Hello World" just use iostream header rather than getting complicated.
1
2
3
4
5
6
7
8
9
10
#include <iostream>
int main()		// C++ programs start by executing the function main
{
	std::cout << "Hello, World!\n";	// output "Hello, World!"
				//wait for a character to be entered
	return 0;
}


I actually did have ../../ twice but I typed it in the post wrong. I've tried the header file at various levels. It is a c++ file. I also tried it at various levels as a text file. At this point, I'm assuming the issue has something to do with the file type.
Last edited on
> At this point, I'm assuming the issue has something to do with the file type.

No. The diagnostic is 'Cannot open include file:'.

The compiler (preprocessor) just doesn't see any file with the name std_lib_facilities.h in the specified directory.
I have even tried naming the actual file with a .h extension.

I'm trying to keep inline with the book. Am I getting bogged down by minutiae? Should I just use #include <iostream> ? He wanted the reader to use
#include "std_lib_facilities.h"
until chapter 10 when he goes over input and output streams in more detail.
Follow the instructions in the book for a temporary fix (for the first several programs):

How do you find std_lib_facilities.h? If you are in a course, ask your instructor. If not, download it from our support site www.stroustrup.com/Programming. But what if you don’t have an instructor and no access to the web? In that case (only), replace the #include directive #include "std_lib_facilities.h" with

1
2
3
4
5
6
7
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
inline void keep_window_open() { char ch; cin>>ch; }


This uses the standard library directly, will keep you going until Chapter 5, and will be explained in detail later.
Disregard this post. I reread the post above.
Last edited on
Topic archived. No new replies allowed.