[英]How do I create a C project in visual Studio 2019?
I installed Visual Studio 2019 and I want to create a C project.我安装了 Visual Studio 2019,我想创建一个 C 项目。 Not C++ and not C# There is no option for a C solution But the doc says VS is both a C and a C++ compiler.
不是 C++ 也不是 C# 没有 C 解决方案的选项 但是文档说 VS 既是 C 又是 C++ 编译器。 I see no option for a C solution.
我看不到 C 解决方案的选择。 There is a doc on the net explaining how to create C project in console from command line.
网上有一个文档解释了如何从命令行在控制台中创建 C 项目。 But I want to create a "normal" project.
但我想创建一个“正常”的项目。
What should I do ?我该怎么办 ?
I'll summarize what was explained in the video someone linked under your question, as I was able to reproduce the steps and create a working C project in Visual Studio.我将总结有人在您的问题下链接的视频中解释的内容,因为我能够重现这些步骤并在 Visual Studio 中创建一个有效的 C 项目。 Kudos to the video creator and kiner_shah for sharing.
感谢视频创作者和kiner_shah的分享。
As a precondition, you shall be able to create C++ project in VS, so make sure you have the right extensions installed.作为先决条件,您应该能够在 VS 中创建 C++ 项目,因此请确保安装了正确的扩展。
Create a new project ( Shift + Ctrl + N ), select Visual C++ and Console App.创建一个新项目( Shift + Ctrl + N ),选择 Visual C++ 和 Console App。 This will create a new console app with a default c++ main file.
这将使用默认的 C++ 主文件创建一个新的控制台应用程序。 Remove that file and put in a
main.c
file.删除该文件并放入
main.c
文件中。 This can be compiled, and works just fine.这可以编译,并且工作得很好。
You should be able to set up the environment by simply adding a ".c" extension to your code.您应该能够通过简单地向代码添加“.c”扩展名来设置环境。 Additionally, you can manually change your environment by opening your file in VS, clicking on the language displayed at the bottom (which should display "Select Language Mode" and choose C.
此外,您可以通过在 VS 中打开文件,单击底部显示的语言(应显示“选择语言模式”并选择 C 来手动更改环境。
C++ can already run C code. C++ 已经可以运行 C 代码。 So just change the extension from *.c or *.i to *.cpp and it should work.
所以只需将扩展名从 *.c 或 *.i 更改为 *.cpp 就可以了。 It's not a GUARANTEE, but 95% of the tome it works.
这不是保证,但 95% 的大部头书都有效。
Select File > New > Project, then select C++, Windows, Desktop, then select empty project in the new project menu.选择 File > New > Project,然后选择 C++、Windows、Desktop,然后在新建项目菜单中选择空项目。 Then click on the folder called "Source" and press Ctrl+Shift+A, then in the new item selection, find the box at the bottom of the dialog, then name it .c.
然后单击名为“Source”的文件夹并按Ctrl+Shift+A,然后在新项目选择中,找到对话框底部的框,然后将其命名为.c。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.