Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VisualStudio没有';我不认识std库 我在C++中在Visual Studio 2015上编写了一个MFC应用程序。我添加了一些代码,它使用std库的成员,并假设获取一个int,然后从中创建一个前缀为“0x”的十六进制字符*。我试图在VS 2015和VS 2017两台不同的计算机上构建该项目,但我得到了相同的错误-VS无法识别std库。我已经在其他程序(Clion)上运行了代码,效果很好_C++_Visual Studio_Std - Fatal编程技术网

VisualStudio没有';我不认识std库 我在C++中在Visual Studio 2015上编写了一个MFC应用程序。我添加了一些代码,它使用std库的成员,并假设获取一个int,然后从中创建一个前缀为“0x”的十六进制字符*。我试图在VS 2015和VS 2017两台不同的计算机上构建该项目,但我得到了相同的错误-VS无法识别std库。我已经在其他程序(Clion)上运行了代码,效果很好

VisualStudio没有';我不认识std库 我在C++中在Visual Studio 2015上编写了一个MFC应用程序。我添加了一些代码,它使用std库的成员,并假设获取一个int,然后从中创建一个前缀为“0x”的十六进制字符*。我试图在VS 2015和VS 2017两台不同的计算机上构建该项目,但我得到了相同的错误-VS无法识别std库。我已经在其他程序(Clion)上运行了代码,效果很好,c++,visual-studio,std,C++,Visual Studio,Std,当我包含#包含时,我得到以下错误: 无法打开源代码文件“stdlib” 我尝试重新安装VS,并且检查我有所有必要的扩展来支持C++,但是我猜仍然缺少一些东西。我怎样才能修好它 守则: std::ostringstream ss; int i = 7; ss << std::hex << std::showbase << i; std::string str = ss.str(); const char *output = str.c_str(); std:

当我包含
#包含
时,我得到以下错误:
无法打开源代码文件“stdlib”

<>我尝试重新安装VS,并且检查我有所有必要的扩展来支持C++,但是我猜仍然缺少一些东西。我怎样才能修好它

守则:

std::ostringstream ss;
int i = 7;

ss << std::hex << std::showbase << i;
std::string str = ss.str();
const char *output = str.c_str();

std::cout << output << std::endl;

谢谢。

我把标题按错误的顺序放进去了。在VisualStudio中的每个C++项目中,它自动包含“代码>”STDAFX.H“/COD>库”。此库包含许多常用库,如
等。解决方案是以以下方式编写包含:

#include "stdafx.h"
// other headers of the form "header.h"

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <strstream>
// other headers of the form <header>
#包括“stdafx.h”
//“header.h”形式的其他标题
#包括
#包括
#包括
#包括
#包括
#包括
//表格的其他标题
而不是:

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <strstream>
// other headers of the form <header>

#include "stdafx.h"
// other headers of the form "header.h"
#包括
#包括
#包括
#包括
#包括
#包括
//表格的其他标题
#包括“stdafx.h”
//“header.h”形式的其他标题
关于这一点,在这本书中再多讲一点


谢谢各位的帮助,我很感激你的时间和注意力。

C++是区分大小写的,代码> > OSTRIGSWATE < /CUL>应该是代码> OSTRIGSWATE 你能得到“Hello World?”吗?@乔治<代码> STDLIB。H/COD>是C标题,<代码> CSTDLIB < /C> > C++,
stdlib
在它们中并不存在如果VisualStudio有这样的问题,人们20年前就会意识到。当项目的include和library路径错误时,就会出现类似这样的错误。你是如何创建这个项目的?您是否尝试过创建一个新项目并进行编译?只需一个简单的控制台应用程序就可以了。@AlanBirtles在我的代码中,我使用了
ostringstream
的小写字母,我很高兴您得到了您的解决方案,感谢您的分享,如果您能将它们标记为答案,我将不胜感激,这将对其他社区有益。@BarrnetChou我将确保尽快将其标记为答案。不幸的是,出于某种原因(可能是因为我是新来的),我只能在发布24小时后将其标记为答案。
#include "stdafx.h"
// other headers of the form "header.h"

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <strstream>
// other headers of the form <header>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <strstream>
// other headers of the form <header>

#include "stdafx.h"
// other headers of the form "header.h"