1

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.

bob
  • 387
  • 2
  • 6
  • 9
  • 1
    Duplicate of http://stackoverflow.com/questions/28605/c-on-visual-studio – Ed Guiness Jan 29 '10 at 09:19
  • I would suggest that now is a perfect time to learn Unix, especially if you're at the stage where you're starting to learn C – Joe Jan 29 '10 at 09:39
  • 1
    just do a normal C++ console project, then rename any .cpp files to .c, visual studio takes care of the rest. – AndersK Jan 29 '10 at 10:29

5 Answers5

7

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
  • 4,261
  • 22
  • 24
  • In English Visual Studio 2008: Configuration -> C/C++ -> Advanced -> Compile As – richj Jan 29 '10 at 09:25
  • 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 Jan 29 '10 at 09:29
  • Right-click on the Project name in the solution explorer.. then settings :) – Christian Jan 29 '10 at 09:30
  • god your going to hate me :D there is no settings when i do this sorry everyone for being so stupid – bob Jan 29 '10 at 09:33
  • Which version of Visual Studio do you use? As an alternative, in the menu "Project" there's a menuitem "Settings", too – Christian Jan 29 '10 at 09:34
  • 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 Jan 29 '10 at 09:37
  • 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 Jan 29 '10 at 09:38
  • 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 Jan 29 '10 at 09:41
  • Or you could just name your files with a .c extension and they will be compiled as C by default. – Nick Meyer Mar 04 '10 at 16:05
2

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
  • 37,799
  • 10
  • 82
  • 91
2

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
  • 3,870
  • 4
  • 39
  • 64
  • 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 Jan 29 '10 at 16:06
  • That's possible ... in which case you can use the package manager to install build-essential, which contains gcc, make, etc. – Duncan Bayne Jan 30 '10 at 02:15
0

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
  • 409
  • 2
  • 10
0

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
  • 21,335
  • 15
  • 77
  • 102