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

Kazi Jawadul Islam Jishan 1 Reputation point
2021-07-14T07:45:19.173+00:00

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".

C++
C++
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,636 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Castorix31 83,206 Reputation points
    2021-07-14T08:15:34.57+00:00

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

    0 comments No comments

  2. rupesh shukla 16 Reputation points
    2021-07-14T22:02:35.353+00:00

    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.

    Thanks

    0 comments No comments

  3. Jeanine Zhang-MSFT 9,431 Reputation points Microsoft Vendor
    2021-07-15T02:06:23.26+00:00

    Hi,

    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,

    Jeanine


    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.