none
How to run C program

    Question

  • Hello, I have my code in C but I cant find a way to run my code. There is an option Attach but It opens a window with the running processes. What do I do next? How can I just compile my code and run it?

    Thank you for your time

    Friday, November 16, 2018 10:08 PM

Answers

All replies

  • This is a good idea, George. C code runs much better if you compile it. And then link it.

    Start here.

    -- pa

    Saturday, November 17, 2018 11:33 PM
  • Hi WantedStarling,

    To compile C in Visual Studio:

    Create New Project -> Visual C++ -> Win32 Console Application.
    Click “Next”.
    Choose “Console Application”, and “Empty Project”.
    Click “Finish”.
    On the solution explorer window, right click on Source Files, choose Add, New Item…
    Type in the file name that ends with .c even if you select .cpp file. 
    And then write your C code and use Ctrl-F5 to compile and run your app.

    Of course, as far as I know, the VS 2017 really updated some project templates:

    https://developercommunity.visualstudio.com/content/problem/110386/how-to-write-and-execute-c-program-in-visual-studi.html

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, November 19, 2018 2:28 AM
    Moderator
  • Hi WantedStarling,

    What about this issue in your side? Would you please share us the latest information in your side? Could you create and run your C app in your VS now?

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 23, 2018 1:25 AM
    Moderator
  • Yes I was able to run my program in C but I also wanna know, every time I open my existing code I again see the option Attach and I have to create a new project and copy paste the code.

    Friday, November 23, 2018 7:38 AM
  • Hi WantedStarling,

    Whether all C apps have the same issue? Which VS version did you really use?
    Could you tell me the steps in your side about how you create this project? Or you create a new one, view the result. For example, I could use the VS2017 in my side like the following steps, but I could find the "local windows debugger" in my side.


    Best Regards,
    Jack



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 23, 2018 8:26 AM
    Moderator
  • To open an existing file I go to File -> Open and then I select my file. Because VS creates a folder with every project I usually save my code from Dev++(with copy paste and then save) and I choose the cpp or c file I want to open. Even If I right click and I choose Open with on a file I still get the Attach option instead of the Local Windows debugger 
    Friday, November 23, 2018 7:04 PM
  • To open a project with intent to build it (remember? It helps to build the code first, else it won't run well), select File-> Open-> Project/Solution. Not open a a file.

    -- pa

    

    Saturday, November 24, 2018 3:14 PM
  • Hi WantedStarling,

    Like Pavel A's suggestion, you need to open the project with the .sln file or the .xxproj file.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 26, 2018 1:20 AM
    Moderator