Today I am going to show you how to create a C project in Visual Studios.

Step 1. Launch Visual Studios and select Visual C++ in the start window. In the Visual C++ section, click on Win32 Console Application. Give your project a name and click submit.

Step 2. A new window should pop out and it should be called Win32 Application Wizard. Click next on the window (not finsish). In the next page, click on Console Application and uncheck the Precompiled Header. Then click finish.

Step 3. You should now see a little bit of code on the screen (that is good). Go to the solution explorer and find the source file menu. Right click on it and add a new item. Now select the C++ file and name it whatever you want but make sure it is a .c not a ** .cpp**.

Final. Now you can start writing C in visual studios...

I hoped this helped some of you guys.

Dani AI

Generated

As @<M/>'s post shows, creating a C project in Visual Studio is mostly a matter of avoiding the C++ boilerplate the templates add. Two simple alternatives give a cleaner starting point: create an Empty Project and add a .c file, or use the console template then immediately turn off precompiled headers and remove any generated C++ files.

Practical gotchas and fixes that aren’t in the original steps:

  • If the build complains about stdafx.h or other precompiled-header errors, set Project → Properties → C/C++ → Precompiled Headers → “Not Using Precompiled Headers” (or add #include "stdafx.h" as the very first line if you keep them).
  • Ensure the compiler treats the file as C: a .c extension normally does this, but to be explicit use Project → Properties → C/C++ → Advanced → Compile As → “Compile as C Code (/TC)”. For a single file, right-click the file → Properties → C/C++ → Advanced → Compile As.
  • To compile quickly outside the IDE, use the Developer Command Prompt: cl /TC hello.c will force C compilation with the MSVC cl driver.

A minimal sanity-check source to add and build:

#include <stdio.h>

int main(void) {
    printf("Hello, world\n");
    return 0;
}

A couple of extra notes: MSVC historically lagged behind GCC/Clang on some newer C-standard features, so code using advanced C99/C11 features may need a different toolchain (MinGW GCC, clang-cl, etc.). If C code is later used from C++ files, wrap C headers with extern "C" guards to avoid name-mangling issues. These tips should complement @<M/>’s walkthrough and address the common problems readers like may hit.

Recommended Answers

All 2 Replies

yes, it will help.. atleast me. thanks a lot. ;)

, No problem :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.