14

I'm currently a freshman in college, majoring in CS. I'm just about done with my "Intro to Computer Programming" class. I like it and feel like I'm learning a good bit.

A couple days ago, I read Joel's The Peril Of Java Schools. "A Linked List?" I thought, "those aren't even hard. We've done a bunch of those already in the class I'm in right now." Which is correct, because in Java, they're not that hard. But anyways, I tried to give writing one in C a try.

And it is SO HARD!

Joel was right, I think ... Java deals with so many little itsy-bitsy things for you that it's really not that hard. But I'm determined to overcome my school's Java-tude and learn how to write this dang linked list in C.

So I guess, instead of trying to ask lots and lots of little tiny questions, I am asking, does anyone know of a good (& free) online tutorial for learning C? Specifically, learning how to deal with pointers, and all those symbols (&, *, **, [] and how they work together) I'd like to think I'm already pretty proficient in Java, so I don't need the tutorials on how to write a "Hello, World!" program. But then I'm definitely not ready to get into any super-advanced C or C++ anything, because all I know is Java.

Any help appreciated!

Jan
  • 460
  • 4
  • 15
  • 9
    The problem with online tutorials is that they are almost always of very poor quality and have pernicious technical errors and other mistakes, or recommend generally poor style coding (I'm not as familiar with online C resources as I am with C++, but for C++, there are no good, free online tutorials). If you want to learn C and how pointers and arrays and other aspects of the language works, do yourself a favor and [get a good beginner book](http://stackoverflow.com/questions/562303/the-definitive-c-book-guide-and-list). – James McNellis Dec 04 '10 at 20:36
  • 1
    I don't know that there is anything to be gained by specifying "from a Java standpoint" because Java doesn't have any obvious analogy to a pointer...probably you just want a [good general guide to pointers](http://stackoverflow.com/q/4016765/2509), and there [are](http://stackoverflow.com/questions/5727/what-are-the-barriers-to-understanding-pointers-and-what-can-be-done-to-overcome) questions for that [already](http://stackoverflow.com/questions/2271490/c-pointers-good-tutorials). – dmckee --- ex-moderator kitten Dec 04 '10 at 20:37
  • Though, [Alf Steinbach's Pointers Tutorial](https://docs.google.com/fileview?id=0B2oiI2reHOh4M2MzNzYwYzQtMGZkNC00NTljLWJiM2UtOGI0MmRkMTMyZGY4) might be useful to you. It's well written, but focuses on C++, not C. You still need a good book though. – James McNellis Dec 04 '10 at 20:40
  • 1
    While I agree with Joel that there are lots things that are being taught badly (or not at all), I strongly disagree in general about how to teach them. I don't think making kids write all that low-level code is a productive exercise. It would be better to produce it in class as a group, talking it over, getting everyone to discuss the errors etc. That way, at a minimum the prof can be there to shout "omfg for the N+1th time at least **read** the damn error!". Having students sit on their own and flail around with zero understanding doesn't lead to more understanding; it leads to plagiarism. – Karl Knechtel Dec 04 '10 at 20:41
  • 3
    +1 for wanting to become a competent engineer instead of just trying to scrape through your classes. – Ed S. Dec 04 '10 at 20:53

4 Answers4

6

Some tutorials:

Some good pointer answers which might help:

The first is a damn good read about pointers and their pitfalls, if you can get past the Pascal syntax.

Community
  • 1
  • 1
Chris Dennett
  • 21,465
  • 8
  • 52
  • 84
3

Check and see if your curriculum requires Systems Programming. Its usually a 300-level sophomore course, and I'm enrolled for that next semester. It is heavily involved working with C+GCC in Unix.

Check your CS dept library, if one exists. I picked up a copy of K&R to work on through winter break.

Jason
  • 10,777
  • 19
  • 81
  • 169
  • 2
    There's no better advice than picking up a copy of K&R's C book. It's small, concise, and clear. – gbc Dec 04 '10 at 20:58
  • 1
    K&R refers to this book: The C Programming Language by Kernighan and Ritchie - http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?ie=UTF8&qid=1291498331&sr=8-1 – Joshua Martell Dec 04 '10 at 21:32
1

This is for C++, not C; but up until about Chapter 3.7 or so talks about stuff at the machine level in a way that's useful for would-be C programmers.

Karl Knechtel
  • 51,161
  • 7
  • 77
  • 117
  • I've not seen that website before, but after a brief glance, I'd argue it should not be recommended as a good C++ resource. It doesn't discuss exceptions at all, so it also doesn't discuss RAII or smart pointers. It eschews the STL containers for its own that are "easier to use." Apparently the author has not programmed much C++ because he states "because the standard library identifiers are used so frequently, it is annoying to have to say `std::` every time we want to refer to one of them." I don't know what the book says about pointers, but I wouldn't trust it. – James McNellis Dec 04 '10 at 20:55
  • @James it does go through exceptions later on, and shows use of the envelope-body idiom for managing polymorphic classes. Concepts are introduces as they become needed. I find it annoying to write `std::` every time, too, and that's precisely because I've written a lot. Half the point of having a real namespace system is to be able to drop the prefixes when it *doesn't* cause a conflict, IMO. Seriously, please don't judge it so quickly. – Karl Knechtel Dec 04 '10 at 21:04
0

There are numerous guides across the internet for learning pointers. Here's one: http://pweb.netcom.com/~tjensen/ptr/pointers.htm which I've used.

I'm also going to suggest this book to you: Hacking, the Art of Exploitation 2nd Ed.

This book will not make you a "hacker". Nothing but lots of reverse engineering / studying binary code, trial and error etc is going to do that. It does, however, introduce to you how you start doing these things and that comes down to a fundamental understanding of how C works, including pointers. Its introduction to assembly/C is one of the best I've seen because it runs you through several C examples and how you investigate what's going on with gdb, a command line debugging tool. That way you can see the C and see the assembly. This includes a fundamental understanding of what pointers are.

This book will as a side-effect give you an introduction to the stack and the heap, data structures etc. In short, reading the intro sections will give you a lot of benefit for the rest of your course.