To keep this simple, I’ll just focus on getting up and running to build console-based C applications. A few of the steps have changed since previous versions of Visual Studio (2017, 2019, 2015, 2013, etc.), so you if you’re familiar with those versions, you might want to have a look at these steps for Visual Studio 2022.
Check System Requirements and Licensing
First, check to make sure your system meets the minimum requirements of Visual Studio Community 2022. You can find the Visual Studio 2022 system requirements here. Also, make sure you read and understand the licensing terms. This free version of Visual Studio can be used for commercial development, if certain criteria are met.
Download and Install Visual Studio
Next, download Visual Studio Community 2022. You can find the Visual Studio Community 2022 download link here.
Then, install Visual Studio Community 2022. When it asks for which workloads you want to include, be sure to select, under Windows, Desktop development with C++. I know we want to program in C, but bear with me. This is how to get what you need for C programming.
Sign In or Sign Up
To keep your free license going, you need to connect the installation with an existing or new Microsoft account. There is no cost to sign up for one. The installer, after installation has succeeded, will ask you to sign in (or sign up for a new account). Take care of this now, at the end of the installation process. If you don’t do this, your Visual Studio Community license will time out after a few weeks.
Create a C Console Project
After everything is completely installed, and you’ve started up Visual Studio Community 2022 on your computer, here’s how you get started building console-based C programs:
- Under Get Started, click Create a new project.
- On the right-hand side of the window, select C++, Windows, and Desktop from the drop-down lists.
- From the choices that appear below that, select Windows Desktop Wizard and click Next.
- Enter the Project name, Location, and Solution name, and click Create.
- In the Windows Desktop Project window, under Application type, select Console Application (.exe). Under Additional options,
check the Empty Project box, leaving all other boxes unchecked. Then, click OK.
- In the Solution Explorer section, right-click Source Files under your project name, and click Add | New Item.
- In the Add New Item window, on the left under Visual C++, click Code. In the middle section of the window, click C++ File (.cpp). Near the bottom of the Add New Item window, in the Name box, type the name of your source file, and be sure to end it with a .C extension (not the .CPP extension that’s already there). If you name your file with a .C extension, it will be built with the C compiler. If you name your file with a .CPP extension, it will be built with the C++ compiler. Click Add.
- The new empty .C source file will be opened in the code editor, and you can type your C source code there. If you need to add more source files to your project, repeat steps 4 and 5 for each new source file you want to add.
If You Build It…
When you’re ready to build your project, click Build | Build projectname, where projectname is the name of your project. When you’re ready to run your program, you can click Debug | Start Without Debugging.
Again, any source files that end with a .C extension will be compiled with the C compiler, and any source files that end with a .CPP extension will be compiled with the C++ compiler.
These instructions should get you started on the path to writing console-based C applications using Visual Studio Community 2022.