简体   繁体   中英

How do I create a C project in visual Studio 2019?

I installed Visual Studio 2019 and I want to create a C project. 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. I see no option for a C solution. There is a doc on the net explaining how to create C project in console from command line. 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. Kudos to the video creator and kiner_shah for sharing.

As a precondition, you shall be able to create C++ project in VS, so make sure you have the right extensions installed.

Create a new project ( Shift + Ctrl + N ), select Visual C++ and Console App. This will create a new console app with a default c++ main file. Remove that file and put in a main.c file. 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. 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.

C++ can already run C code. So just change the extension from *.c or *.i to *.cpp and it should work. It's not a GUARANTEE, but 95% of the tome it works.

Select File > New > Project, then select C++, Windows, Desktop, then select empty project in the new project menu. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM