Adding header file to eclipse

Hello

I am currently reading "Programming Principles and Practices using C++",

I have reached a point where the code includes a "std_lib_facilities.h" header.
So I created a text file, then added all the code there and I created the header file.

But how do I include the std_lib_facilities header in my code so that it works without giving me any errors? I'm using Eclipse.

Why not
#include "std_lib_facilities.h"

You should post your code to get proper help.
http://help.eclipse.org/galileo/topic/org.eclipse.cdt.doc.user/getting_started/cdt_w_existing_code.htm

*not sure if that's what you want, that was the first link on google.

I would actually switch to code::blocks (Just sayin)... I believe that eclipse is used mostly for java? Though I do know some people who like it, generally you can find more user friendly IDEs.
Ok, this is the code:

#include "std lib_facilities.h"

int main()
{
	cout << "Please enter your first name(followed by 'enter'):\n";
	string first name;
	cin >> first name;
	cout << "Hello," << first_name<<"!\n";
}


And this is the error I get:

..\src\Pro.cpp:1:32: error: std lib_facilities.h: No such file or directory
..\src\Pro.cpp: In function 'int main()':
..\src\Pro.cpp:5: error: 'cout' was not declared in this scope
..\src\Pro.cpp:6: error: 'string' was not declared in this scope
..\src\Pro.cpp:6: error: expected ';' before 'first'
..\src\Pro.cpp:7: error: 'cin' was not declared in this scope
..\src\Pro.cpp:7: error: 'first' was not declared in this scope
..\src\Pro.cpp:7: error: expected ';' before 'name'
..\src\Pro.cpp:8: error: 'first_name' was not declared in this scope
Last edited on
+1 ultifinitus, Eclipse is prominent in the Java world. I don't think I've ever seen a company using Eclipse for C++. Why bother learning an IDE that no on uses professionally for C++?
just

1
2
3
#include <iostream>
#include <string>
using namespace std;


instead of "std lib_facilities"
I tried doing what you said ultifinitus but this is what came up:

..\src\Pro.cpp: In function 'int main()':
..\src\Pro.cpp:8: error: expected initializer before 'name'
..\src\Pro.cpp:9: error: 'first' was not declared in this scope
..\src\Pro.cpp:9: error: expected ';' before 'name'
..\src\Pro.cpp:10: error: 'first_name' was not declared in this scope
You can't have spaces in your variable names.

instead of first name

use firstName

(edit) You can, of course use first_name, however it's against my programming method. I like to use blank_blank for functions and methods and lowerUpper for variables and UpperUpper for class names
Last edited on
first name is invalid syntax - first_name would work though.
Topic archived. No new replies allowed.