How to build and run .c source file opened using Visual Studio?

Kazi Jawadul Islam Jishan 1 Reputation point

I am learning to program in C. I used to use Codeblocks earlier to write codes in C. Now I am deciding to switch to Visual Studio, because of its wide variety of supported languages, especially C# and VB.NET. But I cannot find any Build and Run or equivalent feature in Visual Studio after opening a .c file. Instead, there is an "Attachment" option. However, if I write a program for the first time, I can run it by clicking on "Local Windows Debugger".

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,511 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Castorix31 81,356 Reputation points

    See : How to: Create a C++ Project from Existing Code
    (Console application project)

    0 comments No comments

  2. rupesh shukla 16 Reputation points

    Open the solution and Click on Build menu from title bar and you can see Build Solution and Rebuild Solution are there and If you look in Debug option then you can see Start Debugging and Start without Debugging . Those are the options you are looking for. You can also use shortcut , but I think that is not what you are looking for right now.


    0 comments No comments

  3. Jeanine Zhang-MSFT 8,871 Reputation points Microsoft Vendor


    As far as I'm concerned, you couldn't build and run .c source file in visual studio. Visual Studio does not support this. A project is always required, even if it only contains a single source code (.c) file. You could only run the .sln file (Visual Studio Solution) not a .c file in visual studio.

    You could run a single source file through Microsoft's C++ compiler on the command line (cl.exe), and then execute it. But this doesn't involve anything about the Visual Studio IDE.

    If you want to learn about how to create a standard C++ program (C++) in visual studio, I suggest you could start with the Doc: Walkthrough: Creating a Standard C++ Program (C++)

    Best Regards,


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.