Visual studio 2015给我创建一个简单的测试控制台程序的错误 [英] Visual studio 2015 gives me errors upon creating a simple test console program
问题描述
这里是我使用的代码。
#includestdafx.h
#include< iostream>
int main(){
std :: cout<< hi;
return 0;
}
无法打开包含文件'stdio.h':没有这样的文件或者目录
为什么?不应该将stdio.h作为标准库包括在内?
编辑:我刚看过C:\Program文件(x86)\ Microsoft Visual Studio 14.0 \VC \\ \\ include目录。没有stdio.h或stdafx.h。我真的不知道为什么。
$ p $ b这是因为 Visual studio 将路径更改为C标头。
您有相关信息: https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/
我做的是解决这个问题:
转到 Project-> Properties->
。在配置属性 - > VC ++目录 - >库目录
添加一个路径到 C:\Program Files(x86)\Windows Kits \\10\Lib\10.0.10150.0\ucrt\
(选择您的架构)
C / C ++ - >通用 - >其他包含目录
添加路径:
C:\Program Files(x86)\Windows Kits\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ >
注意: 10.0.10150.0 可能会因您的版本而异。
Here is the code I am using.
#include "stdafx.h"
#include <iostream>
int main() {
std::cout << "hi";
return 0;
}
When I create simple c++ console application and try to build it, these errors occur.
cannot open include file 'stdio.h': No such file or directory
Why? Shouldn't stdio.h be included as a standard library? What can I do to get it back?
edit: I have just looked into C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include directory. There is no stdio.h or stdafx.h . I really am not sure why. How can I get them back?
解决方案 That's because Visual studio changed the path to C headers.
There you have the info about that: https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/
What i did to solve this is:
Go to Project->Properties->
. In Configuraton Properties->VC++ Diretories->Library Directories
add a path to C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\
(Choose your architecture)
And in C/C++->General->Additional include directories
add a path to:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt
Note: The 10.0.10150.0 may vary depending on your version.
这篇关于Visual studio 2015给我创建一个简单的测试控制台程序的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!