tags:

views:

509

answers:

16
+5  Q: 

Learning C

I'm a java programmer, wishing to learn C. I want to learn about memory management, making my own data structures, so when asked in interviews, I may be better prepared.

To begin with, what IDE, if any, would you recommend? Thanks

+2  A: 

If you are in Windows, you can get a free copy of Visual Studio C++ 2008 Express.

http://www.microsoft.com/Express/

Edouard A.
I don't know why someone downvoted this. VC++ comes with a nice C89 compiler.
Bastien Léonard
Didn't downvote... but would like to point out that writing C using a C++ compiler should be an offense punishable by termination in my book. If you've got a C++ compiler, then write C++!!! :-)
James Schek
As a C# dev'er, I naturally tried to learn C using Visual Studio. Big mistake. I felt like I had to relearn the IDE and its C/C++ idiosyncrasies before learning thing 1 about C. Although I won't downvote someone's opinion, I HIGHLY recommend against this.
Dinah
VC++ contains a good, standard-compliant C89 compiler (cl.exe), and you can use it with the command-line like GCC if you want. However I think it's better to begin with GCC if you want a command-line compiler (more portable and you can get help more easily I think).
Bastien Léonard
+4  A: 

I would use a combinaltion of gedit (or your favorite text editor w/ syntax highlighting) and gcc.

If you are on a Windows machine I would use CygWin to get access the the gcc compiler. And then use notepad++ for your text editor.

Keep it simple at first. You can move to a more complex IDE after you get the basics down.

Also, for quick reference keep cplusplus.com close at hand. Ignore the c++ stuff, but I find the reference very helpful for c programming.

jjnguy
+23  A: 

C is a nice, lean language. Particularly for learning exercises, I don't think an IDE is all that necessary.

You can do plenty of learnin' with a nice text editor, gcc, and a copy of Kernighan & Ritchie's book.

Indeed, later on, you may find that that's all you'll ever need. But especially for getting started, the extra complexity of an IDE really isn't a benefit.

Legion
+12  A: 

Kernighan & Ritchie's The C Programming Language, 2nd Edition is the place to start. Find a place with gcc and vi or emacs installed and work your way through the examples.

+16  A: 

I would actually just use vim, Makefiles, gcc, etc. You'll learn a lot from that, too, and I really think it's a good idea to get some experience with tools like that. It meshes well with learning C. Makefiles can get pretty gnarly if your project is complicated, but for most of what you will be doing to "learn C" they shouldn't be more than a handful of lines.

Most (all, probably) of what you will be doing will be console apps; use this as an opportunity to get used to the Unix way of doing things. Learn some basic Unix commands, and use them to manage your projects.

Adam Jaskiewicz
Even if you are on windows, the "Unix way" is a good way to go. MinGW + MSYS + gcc + vim makes a good devlepment environment.
daotoad
I was thinking cygwin, but yeah.
Adam Jaskiewicz
Thanks for the link.
Liran Orevi
A: 

I like Visual Studio. Express versions are free.

theG
A: 

It depends what you want to do and how much you want to spend. When I was starting out in C, I used an IDE called PellesC; it's free and I found it very easy to use and very useful.

However, one problem that I found with it was that some of the Windows GUI libraries aren't supported fully, so if you later on want to go down that route, then perhaps something like Visual Studio would be more appropriate - the express versions work just fine if you're not prepared to pay the large price tag for the pro version.

Perspx
+4  A: 

You don't need an IDE for everything, especially just learning. Just go with a basic text editor: Vim, Emacs, TextMate (if you're on a Mac), or whatever your personal preference is (I don't know what's popular in the Windows world, or if you're even using Windows). And pick up a copy of Kernighan and Ritchie's The C Programming Language -- it's indispensable for learning C.

mipadi
+2  A: 

I'm going to echo everybody here who says "don't use an IDE", and also explain why. C originated in an era where text editors were still cutting-edge technology, and as such, was designed from the get-go to be something that a programmer could write without needing extra tools to handle all the busywork.

C thus has zero boilerplate code, even though the language itself has grown quite a bit over a few years. Everything you do in a C program has a definite purpose, and if you want to learn the language, you should understand why you're typing things in. An IDE that handles things for you doesn't force you to deal with the details of the language yourself.

IDEs are tools for the working programmer, not the student programmer. Just as computer algebra systems (like Mathematica) are tools for mathematicians, not beginning Calculus students.

So, use a good text editor: vim or emacs. Although I am am vim user, I'd recommend emacs (if you're getting started with editors), just because it's more programmer-oriented.

Also, I suggest you first learn C on Linux, BSD, or some other flavor of Unix. That's where the language grew up, and understanding Unix will help you in turn understand C better.

Don Werve
Tom
@Tom: Tell that to all the Windows developers who wrote their apps in C for years.
Robert S.
A: 

You could use Eclipse, esp if you are familiar with it from Java, just so you have access to a compiler.

When I started I used vi and gcc but that was on Solaris.

It may help if we knew what OS you were using, or had access to, but, you don't need an IDE, but it can be helpful.

The hardest part, for me, about learning C was pointers, and I expect you will get questions on that, so you may want to study up on those.

Good luck.

James Black
A: 

I hear what everyone is saying about using notepad/vi and gcc.

However I use Borland's Turbo C++ (on Windows), it's also free and has a C compiler. I've no complaints about it.

Patrick McDonald
Does Borland C++ support C99 at all?
Chris Lutz
Patrick McDonald
+1  A: 

i'd recommend getting K&R plus some most recent book because K&R can be tough at times, or at least it was for me, e.g for some reason i was never able to understand pointers by myself from the explanations in K&R and only got it right when i finally learned C at uni.

also, i believe somewhere on the web you can find guides for the K&R book, such as these Notes to Accompany The C Programming Language, by Kernighan and Ritchie and also i'd recommend that you always check the C-FAQ website once you start coding and all kinds of questions start to pop into your head (for example: "omg why can't i assign a new string to this char *c variable???"). it's all explained on there.

i think, more important than working or not working on an IDE is that whatever you do, at some point you should use a debugger to see how things really happen under the hood. especially when you start doing pointer arithmetic and stuff.

but if you want to deal with the whole compiling thing then just install gcc and the text editor of your choice.

Xander
+1  A: 

The first step to learning C is to find a motive better than doing good at job interviews.

idrosid
A: 

If you want an IDE, Bloodshed Dev-C++ is a good choice. It's free software, and the source code is available.

I personally like Vim, but there's somewhat of a learning curve before you can become comfortable with it.

Nighthawk
A: 

I agree with the others that an IDE isn't the big thing. For sure start with the K&R C book as others have stated, but follow up with "Expert C Programming" by Peter Van Der Linden. It's a surprisingly easy and fun read, and will cover a heap of ambiguities and errors that occur while working with C... and even goes over a few classic interview questions at the end.

uzi
A: 

If you want a nice IDE, Eclipse has a nice C/C++ extension

http://www.eclipse.org/cdt/

Yada