Creating a C Project in Visual Studio

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.

  1. Open Visual Studio
  2. Select File –> New –> Project… (or CTRL+SHIFT+N for you keyboard fanatics)
  3. 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++
  4. In the Project window, select Win32 Console Application
  5. Give an appropriate name to the project.
  6. The Win32 Application Wizard dialog box should appear
  7. Click Next at the Welcome to the Win32 Application Wizard page
  8. On the Application Settings page, make sure the following are selected:
    1. Application Type: Console application
    2. Additional Options: Empty Project
  9. Click Finish
  10. You now have a new “C” project

The following steps walk you through creating the actual C files.

  1. If Solution Explorer is not visible go to View –> Solution Explorer
  2. Right click the Source Files folder in Solution Explorer and select Add –> New Item…
  3. The Add New Item dialog box should appear.
  4. Select C++ File (.cpp) and name it an appropriate name, such as main.c (make sure to give it a .c extension)
  5. 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.

Happy coding!

2 thoughts on “Creating a C Project in Visual Studio

  1. hi i’ve started learning c today and am using visual studio 2008 aas per ur instrucions….i have written a basic hello wrld progrm but when i run it there appears to be some error saying “Native’ has exited with code 0 (0x0).”…can u please help?

    1. This is normal. It just means the program exited without error. When debugging your C-code within Visual Studio the program will run and then execute once it has finished. To prevent this you may try adding getch(); at the end of the program. This will wait for a user to enter a character before the program exits.

      You will also need to add the following include statement if it isn’t already in your program: #include . You can place this at the top of the program.

      Hope that helps!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s