If you’re in love with Visual Studio as I am, you would probably prefer to do all of your coding day in and day out in Visual Studio. However, sometimes some languages may not appear as if they are supported in Visual Studio. One of those languages is C. Visual Studio is well known for its support of C++ projects, but doesn’t explicitly list C as a language. Because C++ contains all of the features/functionality of C, the VS C++ compiler will also compile any C code you write. To create a C project in Visual Studio you just need to create an empty C++ project and add any appropriate .c / .h files as needed. All will compile and work just fine.
Here’s how you can start a new C project within Visual Studio.
Note: This tutorial is designed/tested around Visual Studio 2012, the latest version of Visual Studio available as of this writing. However, this should work for any version of Visual Studio.
- Open Visual Studio
- Select File –> New –> Project… (or CTRL+SHIFT+N for you keyboard fanatics)
- When the New Project dialog box appears select Visual C++ in the left pane. (You may need to go to Templates –> Other Languages –> Visual C++
- In the Project window, select Win32 Console Application
- Give an appropriate name to the project.
- The Win32 Application Wizard dialog box should appear
- Click Next at the Welcome to the Win32 Application Wizard page
- On the Application Settings page, make sure the following are selected:
- Application Type: Console application
- Additional Options: Empty Project
- Click Finish
- You now have a new “C” project
The following steps walk you through creating the actual C files.
- If Solution Explorer is not visible go to View –> Solution Explorer
- Right click the Source Files folder in Solution Explorer and select Add –> New Item…
- The Add New Item dialog box should appear.
- Select C++ File (.cpp) and name it an appropriate name, such as main.c (make sure to give it a .c extension)
- Start coding!
That should be all you need to know to create a new C project in Visual Studio. If you have any questions, feel free to leave a comment below.