views:

354

answers:

2

How can I create a basic C app in Visual Studio, be it 2010 Ultimate or 2008 Professional? I have searched through the project templates, and can find plenty for C++, but none for C.

(I'm hoping that the compiler and debugger will be built in.)

+2  A: 

Visual Studio doesn't have a separate compiler for C, it uses the C++ compiler for C code. You can tell it to restrict itself to legal C syntax by using a compiler switch or by renaming the .cpp file to .c

Edit: I'm still using 2005 on this machine, so it might not be in the same place, but try this

  • Right click on the main.cpp in the solution explorer pane (on the right).
  • Choose Properties (bottom of the menu)
  • Open up the C/C++ group of properties
  • choose Advanced page
  • Change "Compile As" property to "Compile as C Code (/TC)"
John Knoeller
+1 You are faster ;)
AraK
What would that compiler switch be, and would I set it?
Rosarch
By default, it judges by extension. You can override that in the project properties.
Seva Alekseyev
@Rosarch use `/Tc`: http://msdn.microsoft.com/en-us/library/bb384838.aspx
AraK
@AraK: not always ;)
John Knoeller
+2  A: 

New project/Win32 Console Application/Empty project.

Add a file called "hello.c" (important that it's .c)

Type out a basic hello-world:

#include <stdio.h>

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

Compile, execute... PROFIT!

Seva Alekseyev
Your last words made me laugh!!! incidentally, someone posted a question asking would anyone be interested in a 'hello world' http://stackoverflow.com/questions/2168417/would-you-buy-a-hello-world-t-shirt-closed...now that's PROFIT!!! :) +1 from me...
tommieb75
+1 for PROFIT!!
Rosarch