tags:

views:

5788

answers:

13
+3  Q: 

C on Visual Studio

I'm trying to learn C. As a C# developer, my IDE is Visual Studio. I've heard this is a good environment for C/C++ development. However, it seems no matter what little thing I try to do, intuition fails me. Can someone give good resources for how to either:

  • learn the ins and out of C in Visual Studio
  • recommend a better C IDE + compiler


Edit: See also: http://stackoverflow.com/questions/951516/a-good-c-ide

+1  A: 

Some people say that a smaller IDE is better for learning. Take a look at Code::Blocks. It's generally true that beginning C in an IDE is hard because not many books explain enough to control the IDE. Perhaps starting in a console and a basic text editor with syntax highlighting would be better – at least under Linux. Since Windows' console is far from great, I'd not recommend using it.

/EDIT: Dev-C++ used to be the best freely available IDE for Windows. However, it's development has been discontinued years ago and the most recent version unfortunately is full of bugs.

Konrad Rudolph
+7  A: 

Answering the purely subject question "recommend me a better C IDE and compiler" I find Ming32w and Code::blocks (now with combined installer) very useful on windows but YMMV as you are obviously used to the MS IDE and are just struggling with C.

May I suggest you concentrate on console applications to get a feel for the language first before you attempt to tie it together with a windows UI which in my experience is the hardest bit of windows development.

sparkes
+1  A: 

Bloodshed Dev-C++ is the best windows C/C++ IDE IMO: http://www.bloodshed.net/ It uses the GNU compiler set and is free as in beer.

EDIT: the download page for the IDE is here: http://www.bloodshed.net/dev/devcpp.html

mmattax
+5  A: 

Simple and sweet: Console applications (basic C programs using printf and such) are easily and cheaply done with the Tiny C Compiler - a no frills, no gui, complete C complier.

http://bellard.org/tcc/

However, C development is relatively simple on Visual Studio as well. The following instructions will set Visual C++ up as a good C compiler, and it will produce console applications at first, and yo can move up into more complex windows apps as you go.

  1. Get the Visual Studio C++ edition (express is fine)
  2. Start a new project - disable pre-compiled headers (maybe the wizard will let you do this, maybe you'll have to change the compiler settings once inside the project)
  3. Delete everything inside the project.
  4. Create a new "example.c" file with the hello world example
  5. Compile and away you go.

Alternately, get a linux virtual machine, or Cygwin. But as you already have Visual Studio, you might as well stick with what you know.

As an aside, this isn't Atwood learning C finally, is it? No ALTs! ;-D

Adam Davis
+1  A: 

http://xoax.net/comp/cpp/console/Lesson0.php

Any use?

Rob Cooper
A: 

On an unrelated note: What do you really want to learn? C as you wrote in the title or C++? Don't make the mistake of thinking they're (almost) the same – they are not. If you want to write one of the two, I'd strongly advise against C and for C++. Stroustrup (the inventor of C++) has an insteresting argument on his site.

Konrad Rudolph
Advice appreciated but I really do mean C
Dinah
+5  A: 

The problem with learning C within Visual Studio is that you are compiling C using the Visual Studio C++ compiler. You might want to try learning C using the GNU GCC compiler from within the Cygwin environment in Windows.

Antonio Haley
This is good advice. Most C code libraries out on the internet won't have the Microsoft trappings like _tmain() or #include "stdafx.h" and trying to learn C at the same time as learning the differences for the Windows environment is a headache you don't need.
Kelly French
+4  A: 

As already said, you should check out the VS.net C++ edition, but if you'd like to try something else Eclipse has a C++ edition. You can get more info from http://eclipse.org or check out the distro at http://www.easyeclipse.org/site/distributions/cplusplus.html

codeLes
+3  A: 
The problem with learning C within Visual Studio is that you are compiling C 
using the Visual Studio C++ compiler. You might want to try learning C using
the GNU GCC compiler from within the Cygwin environment in Windows.

This is a legitimate response, I posted an IDE that uses the GNU compilers, so why has he been down modded?

This is the type of thing that will make me not use SO, why down mod someone just because they are recommending a different compiler, and IMHO, a better one then Microsoft's?

get real people, and @Antonio Haley I gave you +1

mmattax
+2  A: 

There's a very good reason to learn C and C++. The reason is that there's a lot of C and C++ code out there that are performing very real and important tasks. Someone who considers themselves a programmer and a learner(doubtful that you can separate the two) can learn a lot from these lines of code.

You can learn a lot from each language by studying the other, but if you really want to grok C it's a lot easier to separate yourself from anything C++ for a while. Visual C++ is great but GCC is a great way to thrust yourself into vanilla ANSI C without having to mentally sidestep any C++.

@mmattax thanks!

Antonio Haley
+1  A: 

C in Visual Studio is fine, just use the command line compiler that is included in the Pro edition. Yes its the C++ compiler but treats all files ending .c as C . You can even force it to treat ALL files as C with a switch. The VS documentation has entries on it, just search the index for Visual C.

A: 

Does VS produce "managed" code that requires the .Net framework or will it compile to machine code for a given architecture. Forgive me if the question does not make sense.

James
John Saunders
Apologies, I just didn't want ask a question that could be easily answered here.
James
Please ask this as a new question...
Marc Gravell
+1  A: 

Visual Studio is one of the best IDEs for C/C++. I don't think it is complicated and hard to use - if you have questions about it - ask them. Some other compilers/IDEs are fine too, but if already have Visual Studio and have used it - why not stick to it?

devdimi