开发者

Learning C - Want to use visual studio

开发者 https://www.devze.com 2022-12-18 16:20 出处:网络
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 enoug

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 hav开发者_C百科e 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.


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 :)


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消