我正在从Bjarne Stroustrup的“编程:原则和实践”中学习C++。他们给出了一个示例程序:
// read and write a first name
#include "std_lib_facilities.h"
int main()
{
cout << "Please enter your first name (followed by 'enter'):\n";
string first_name; // first_name is a variable of type string
cin >> first_name; // read characters into first_name
cout << "Hello, " << first_name << "!\n";
}当我在visual studio中键入相同的代码时,它给出头文件"std_lib_facilities.h“的错误。我对这个头文件感到困惑。
它还在使用吗?除了这个头,我还能用什么?
发布于 2018-11-04 21:36:10
在“编程:使用C++ -的原则和实践”这本书的附录(具体来说是C.3.2)中,您实际上可以找到作者解释了这个特定的头文件- std_lib_facilities.h,并且他留下了一个供读者下载的链接(http://www.stroustrup.com/Programming/std_lib_facilities.h)。
由于学习者必须下载文件并将其放在您选择的目录中,因此我从这一点推断出,该文件不是人们实际使用的头文件,而只是用于教学用途。
发布于 2020-08-03 14:06:57
来自Bjarne Stroustrup的网站(Homepage)
实际上,std_lib_facilities.h的原始URL是:https://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h
但在写这篇文章的时候,它给出了404未找到错误。
但是,如果我们从URL的路径中删除"Programming“一词,使其成为:https://www.stroustrup.com/PPP2code/std_lib_facilities.h
我们从官方网站上获得了库的代码。
希望将来Stroustrup先生能纠正这个问题。
发布于 2020-07-14 17:50:26
Bjarne Stroustrup在“编程:使用c++的原则和实践”中列出的链接已经过时了。事实上,Stroustrup网站的整个部分https://stroustrup.com - https://stroustrup.com/programming都已经过时了,你在网站主页上也找不到它。
因此,正如Jon提到的,您可以在此处找到更新的工作版本的github存储库:https://github.com/BjarneStroustrup/Programming-_Principles_and_Practice_Using_Cpp/blob/master/std_lib_facilities.h。
要使用此文件,请从存储库复制代码并打开文件资源管理器。转到计算机上安装MinGw的文件夹(如果您的PC上安装了MinGw )如果没有,请从以下位置下载MinGw:https://sourceforge.net/projects/mingw-w64/
请在此处查看MinGw的安装过程:https://www.youtube.com/watch?v=bhxqI6xmsuA
安装MinGw后,转到安装MinGw的文件夹,然后单击在其中看到的include文件夹。在其中,创建一个新的文本文件(单击new item -> text file),并粘贴从github存储库复制的代码。将文件另存为std_lib_facilities.h并关闭文件资源管理器。
现在你的代码运行起来没有任何问题了!
希望这个答案对你有帮助!
https://stackoverflow.com/questions/45877104
复制相似问题