Please help

I`m trying to run a .c file from Visual Studio. When I double click on the file it opens automatically in Visual Studio but I can`t compile it. Ctrl+F5 doesn`t work. What should I do?


  • I hate Visual Studio, for some reason it seems to compile whole projects only and stuff like that. It's really for advanced programmers.
    I'd recommened you to use another IDE. I, personally, prefer Code::Blocks.
  • Thanks. I thought there is a way.
  • [color=Blue]What kind of .C file it is?
    Is it console application? If it has main() - then it is Console. If it has WinMain() then it is Win32 GUI application.

    1. Open Visual Studio
    2. Select File -> New -> Project from menu bar
    3. In the tree on left side select Visual C++ -> Win32 item
    4. Select "Win32 Console Application" or "Win32 Project" depending on your .C file contents
    5. In "Location" edit box enter your directory for projects, like: "C:My VS Projects"
    6. In "Name" edit box type any name for your project, like "Test01"
    7. Leave "Create Directory for solution" un-checked
    8. Click Ok
    9. Click "Next" in next dialog
    10. Check "Empty Project" box
    11. Click "Finish" button
    12. You will get a tree view of your project. It will be on left side or on right side depending on VS initial settings. Tree will have three folders: "Header files", "Resource files" and "Source files".
    13. Switch to some File Manager program, like Windows Explorer and copy your .C file into the directory created in steps 5,6 - it should be "C:My VS ProjectsTest01", because it is combined from the names of directory and your project name.
    14. Switch back to VS
    15. Right click on "Source Files" in the tree and select "Add -> Existing item".
    16. Browse to your file you copied in step 13 and select it.
    17. Click "Add" button.
    18. Select "File -> Save All" from menu bar
    19. Select "Build" -> "Build Solution" from menu bar
    20. Click F10 - debugger will stop on the first line of your program. Provided, of course, that you have no build errors.
  • Thank you for the detailed explanation. I thought there should be a way to run a C file without creating a project and all the long procedure. But I guess there isn't.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!