views:

841

answers:

10

I come from a PHP based background and my new years resolution was to listen to Joel and learn C.

I am using a Windows based PC and I don't mind programming that's focused a little on the Windows side though I will be starting with console applications.

  • What compiler could I use and why?
  • What IDE could I use and why?
  • What other tools are useful for a beginner C programmer?
  • Are there free online guides?

I tried to look for SO questions but the C tag has no good questions on the Hot list but if you know of some good SO questions that are related to this one, don't hesitate to add it here below.

SO Posts

+2  A: 

See this stackoverflow post for a list of books and online resources on C programming, plus, of course, K&R. - which is actually quite a good book and mercifully short. The classic C on Win32 work is Petzold's Programming Windows.

EDIT: Per my addition to tvanoffsson's post, the MinGW suite is good for console apps. Also, a friend of mine wrote a C programming tutorial a few years ago which was quite well known at the time and still pops up on occasion.

ConcernedOfTunbridgeWells
I wouldn't confuse the issue by throwing the Win32 API into the mix. Start with ANSI C. Console applications.
cletus
The OP did say that he was going to work on Windows, where the Win32 API will inevitably make its presence felt. However, the advice to start with the basics is sound.
ConcernedOfTunbridgeWells
I should have been clearer, since i didn't know if the compilers were different for windows or something, i will be starting with console apps.
Ólafur Waage
+7  A: 

You might try using the Visual Studio Express C++ Edition. You can easily write C code and compile it with a C++ compiler. I'd buy a copy of K & R C and work through it.

EDIT: As an alternative to Visual Studio, you could look at MinGW. This is a Win32 development system based on GCC. The main claim to fame of this over Visual Studio is that unix-centric C resources will work better on this than on Win32 as it has ports or clones of many of the main Unix libraries, which may or may not be available with Visual Studio or may not be totally compatible without some porting work.

tvanfosson
Just curious - How do you configure visual studio to behave like a traditional C compile and only compile true C?
Doug T.
For the OP's purposes, that probably doesn't matter, however it will leave some elephant traps for the uwary.
ConcernedOfTunbridgeWells
A: 

MicroSofts Visual Studio Express (Now part of some .net package) is an excellent IDE/Compiler toolset and more or less free to dowload!

I would also recommend Kernigen and Ritchies "The C programming language" the definitive book on C before C++, and, one of the best pieces of technical writing ever.

Avoid Bjarne Soustrups "C++" book, its a very hard read and more about how/why to define programming syntax than how to use the langauge.

James Anderson
A: 

The only problem with using the C++ compiler is it isn't straight up C, but I would suggest learning C++ is just a good to learn as C. I would suggest learning C++ no matter what Joel says....since he probably thinks of them as the same. Pointers, pointers, pointers....

I would suggest this C book if you are bent on straight C.

kenny
I think the motivation behind Joel's recommendation to learn C is to get an insight into how the machine works at a low-level. IMHO, C is better than C++ for this and is much, much simpler.
ConcernedOfTunbridgeWells
MS Visual C++ fully supports the latest definition of palin C.Just put a ".c" extension on the source file!
James Anderson
@James, MS Visual C++ does not support C99.
banister
+2  A: 

I'd start MinGW (or Cygwin) on Windows or just Gcc on *nix. IF you want to learn C programming and IDE shields you from the important process of compilation.

Learning a language like C is like every other language. Start with a few simple "Hello, World" programs and understand them. Move onto something small that you need achieve. You'll be fluent in the core language in no time; it's quite small and there are only a few things you need to be really aware of as you're starting out (pointer<=>array duality is one).

Understand the pre-processing, compilation and linking phases of development too. For hello world it's as simple as

gcc hello_world.c

But in any large program you will do separate compile/link phases. The IDE like MSVC will handle this for you, but you still need to be aware of it.

By all means, find a good IDE with good syntax hilighting but start out only using the editor features for a bit.

Adam Hawes
+8  A: 

I'll answer your questions in order:

  • What compiler could I use and why? - Generally, gcc on the Unix world, and since you said you don't mind Windows, the latest version of MSVC (2008). though it doesn't support C99. (Remember to change the project settings to compile as C.)
  • What IDE could I use and why? - I've heard good things about Eclipse, but I never got much into it since I'm on Windows, and gcc options for Windows are... not stellar. MSVC 2008 is good, but Intellisense doesn't quite live up to C#, though it isn't as important in C as in C++. I've heard they're fixing this for 2010.
  • What other tools are useful for a beginner C programmer? - Turn up your warning level to the maximium supported by the compiler. (To a reasonable standard.) This will help you mantain good coding practices.
  • Are there free online guides? - Yes. I don't know of any very good ones though. Get K&R 2nd Ed. It's an awesome book, and short too, by the creators of the language.

And another bit of advice: Try to stick to, and learn, standard ANSI C first, stay away from proprietary extensions.

yuriks
Thanks so much for answering so precisely, and i like the comments about the maximum warning levels and standard ANSI
Ólafur Waage
A: 

The option you're going to want to go with for a compiler is gcc if you'll be working with K&R C (which you should). You can do this through Cygwin, which will also help you brush up on your Unix skills if you don't already have a basic level of familiarity with *nix.

For a beginner, an IDE is definitely overkill here. Therefore I'd suggest learning to work with vi, emacs, pico, or joe. All are available with Cygwin as well, and which one you choose should be a matter of personal preference. Each comes with its own learning curve. Later on, you may find you prefer one of these editors to Visual Studio (or any other IDE for that matter.)

It is a good exercise to learn to do all of this without an IDE first.

In the end, however, the most important thing is not that you worry about the platform, but simply that you pick up the tools and begin using them. There's no other way to learn.

Max
A: 

After K&R (aka The Bible in my CS class), I would recommend this book: link text It covers some of the tricky parts of C and is very well written. And you even get a certificate of completion. How could you beat that!

laconicdev
+1  A: 
  • What compiler could I use and why?

I have to agree that creating and running programs manually at first (without the help of a IDE) will be beneficially, even if it's only for your first few small programs. As mentioned above GCC is very standard.

  • What IDE could I use and why?

I started out using DevC++ (it is easy to use). Then, depending on your direction you will then want to choose a more sophisticated IDE (such as Visual Studio).

  • What other tools are useful for a beginner C programmer?

Your IDE's debugger! Instead of placing "printf" statements everywhere (like many beginning c-programmers do) learn how to use your IDE's debugger. It will save you quite a bit of time in the long run :)

  • Are there free online guides?

Tons. A quick google search for "c programming" will return massive amounts. But, if you really want dive in, I recommend searching for common C Programming college course prefixes (such as COP3223). If you snoop around a bit with that you will be able to find some great lecture notes that will be very beneficial!

lifeR00t
+1 for the lecture notes
Ólafur Waage
A: 

What compiler could I use and why?

GCC, because it's universal: you can run it on Windows, OS X, Linux, Solaris, Haiku, anything you mention, and on any kind of CPU (i.e. architecture), and for any kind of CPU. Your compiler-specific skills are never obsolete with GCC.

For windows, that'd be MinGW.

What IDE could I use and why?

Emacs. Press tab once, emacs automatically indents the right way. Moving through text is done effortlessly with Ctrl-letter and Alt-letter, instead of by moving your hand all the way over to the arrow keys or page up/down (although you do have that option). Yeah, it sounds weird, but it's a boon once you get the hang of it. The colors are pretty to look at and easy to read (unlike vim's dark-blue-on-black comments).

You may like ecb-minor-mode, which works well with window-numbering. Also, there's a great IRC channel, #emacs, on irc.freenode.net.

What other tools are useful for a beginner C programmer?

A debugger. Note that gdb takes a little while to learn, but is quite nice.

Also: Valgrind. Very useful for checking your program for errors regarding dynamically allocated memory. Also very useful for finding threading bugs (if you need that).

Are there free online guides?

They come and change and go. I punt this one and let Google give the answer.

Jonas Kölker