views:

192

answers:

5

I am trying to get cracking with my C module at uni, however I can't seem to get an IDE to work. I want to use Visual Studio though I guess I should be using Unix (I just don't understand Unix enough yet).

How in Visual Studio 2008 do I set up a project to work with C? I have used Visual Studio for VB.net before and it was a doddle to use, this is proving somewhat harder for some reason.

I just don't know what I am supposed to do in the setting-up stage to get to code if you know what I mean, all I could see was C++ as an option as it has many sub-sections, none of which I could see were relevant.

+1  A: 

To create an empty C/C++ project:

New -> Project... -> Visual C++ -> Win32 -> Win32 Console Application -> Next -> Tick "empty project" -> Finish.

Now go to the Solution Explorer (usually on the left side of the IDE), right click on "Source Files" and click Add... -> New Item -> C++ File (.cpp). In that file, write your code then compile and run.

You can then switch from C++ to pure C in the Project Properties or by renaming your file to .c.

Max Shawabkeh
+6  A: 

You can create a standard C++ console application (or a MFC/Win32 one, depending on what you need) and then make a change in the project settings, so it's treated as C code: Configuration -> C/C++ -> Advanced -> Compile As. Set this to "Compile as C code".

Or simply pass the /TC flag to the compiler :)

Christian
In English Visual Studio 2008: Configuration -> C/C++ -> Advanced -> Compile As
richj
Thanks, I'll correct that :)
Christian
cant seem to find configuration, i followed the poster below to get to a screen where i can type in code New -> Project... -> Visual C++ -> Win32 -> Win32 Console Application -> Next -> Tick "empty project" -> Finish.but cant seem to find the configuration bit
bob
Right-click on the Project name in the solution explorer.. then settings :)
Christian
god your going to hate me :D there is no settings when i do thissorry everyone for being so stupid
bob
Which version of Visual Studio do you use? As an alternative, in the menu "Project" there's a menuitem "Settings", too
Christian
i am using 2008
bob
Okay, there must be something like Settings or Properties in either the "project menu" in the main menu bar or when you right click on the project name in the solution explorer.
Christian
yes properties, but there is a whole lot of stuff in there which i am not sure i am comfortable changing as i am not sure where to start :)
bob
See my post for which path to follow in the properties. There you'll find the compile as setting, which you have to set to "Compile as C code"
Christian
Or you could just name your files with a .c extension and they will be compiled as C by default.
Nick Meyer
+2  A: 

First things first ... C++ is not C. They are different languages. There is no such thing as "C/C++".

Secondly - it's not that hard to start using GNU/Linux as a development environment, especially for C. I suggest taking a look at the following:

  1. Ubuntu. You can burn yourself an Ubuntu CD, boot from it, and try out Ubuntu without installing anything. When you're happy, installing a dual-boot system (i.e. without destroying your Windows partition) is a matter of a few clicks.

  2. KDevelop. Once you're running Ubuntu, you can use the package manager to install KDevelop, which was my favourite C IDE (back in the day when I cut C code for a living).

If you get stuck with Ubuntu, there's a very helpful community at the Ubuntu Forums.

In terms of C, check out comp.lang.c.moderated (seems a lot less spammy than comp.lang.c which was popular around ten years ago). Also check out the the comp.lang.c FAQ which is a treasure-trove of advice.

Duncan Bayne
I seem to remember that the last Ubuntu livecd I got didn't actually come with GCC. That was a few years ago though.
Joe
That's possible ... in which case you can use the package manager to install build-essential, which contains gcc, make, etc.
Duncan Bayne
A: 

I suggest to give Dev-C++ a try. It has a number of built in sample projects that'll help you get started, and it has very nice package manager, that'll help install libraries like boost and opengl/glut. After gaining some basic knowledge of c/c++ you could move more easily to other IDEs.

zslevi
A: 

Make sure that Visual C++ is installed. You may only have installed Visual Basic .NET.

Then when you create a project, you should have a Visual C++ project type to choose from.

spoulson