Self-taught C

S

Sleepy Duke

What are the best methods you all have found for teaching yourselves how to code proficiently in C?
 
B

Bl0ckeduser .

What are the best methods you all have found for teaching yourselves how to code proficiently in C?

I'm a teenager who writes in C as a hobby. Obviously my advice
won't be worth much, but here it is:

K&R was more in-depth than the web tutorial I first read.
I also learnt a few things from reading the old Unix sources
(http://minnie.tuhs.org/cgi-bin/utree.pl). I'm pretty sure writing
a lot of code helps.
 
M

Malcolm McLean

What are the best methods you all have found for teaching yourselves how to code proficiently in C?
Basically do it.

If you're sitting in a bedroom on your own, the most likely thing
you'll want to code is a game. So get graphics working as fast as you
can. It's harder now than it was to get a simple character-based
raster that can be used for moving space invaders round the screen.
But that's usually the best place to start.
 
N

Nick Keighley

What are the best methods you all have found for teaching yourselves how to code proficiently in C?

write lots of code.

the best way I found was already knowing anothe couple of programming
languages, but this probably doesn't help...
 
N

Nick Keighley

I'm a teenager who writes in C as a hobby. Obviously my advice
won't be worth much, but here it is:

if you are a competent C programmer then your advice may well be
useful. It probably helps that you learned C recently so you have a
better memory of the process
K&R was more in-depth than the web tutorial I first read.

yes. Most web tutorials are, sadly, crap. K&R is great, though some
find it a bit heavy going. They don't waste words.
I also learnt a few things from reading the old Unix sources
(http://minnie.tuhs.org/cgi-bin/utree.pl).

I'm pretty sure writing
a lot of code helps.

absolutely. Learn by doing.
 
G

gwowen

write lots of code.

That.

It'll help to have a project or something that you want to accomplish,
and work htowards that goal.

Set your compiler to its most picky settings, and understand every
single diagnostic message it gives you. And them eliminate them,
figuring out what misunderstanding led to them occuring in the first
place.

Then run the code under valgrind or some similar bounds/leak checker
and understand all its diagnostics too.
 
J

Joe Pfeiffer

gwowen said:
That.

It'll help to have a project or something that you want to accomplish,
and work htowards that goal.

I think that's the most important single advice that can be given.
 
F

Fritz Wuehler

It'll help to have a project or something that you want to accomplish,
I think that's the most important single advice that can be given.

Agreed. But working at a support role where you have to read lots of code
and fix it is even better than that and along with it, you'll have it all.
 
N

Nick Keighley

Agreed. But working at a support role where you have to read lots of code
and fix it is even better than that and along with it, you'll have it all..

dunno, being a maintenance programmer on a nasty pile of code can be a
dispiriting experience. I wouldn't suggest i was necessarily a good
way to learn.
 
J

James Kuyper

What are the best methods you all have found for teaching yourselves how to code proficiently in C?

1. Study "The C Programming Language" by Kernighan & Ritchie. However,
I've heard that this is not a good introductory book for someone with no
previous experience in programming. I wouldn't have noticed if that were
the case - C was my fourth programming language, after FORTRAN I (sic),
Basic, and APL.

2. Write lots of code while trying to achieve very specific goals. If
you don't have a specific goal you're trying to achieve with the code,
you won't learn as much while writing it.
 
S

Stefan Ram

Sleepy Duke said:
What are the best methods you all have found for teaching
yourselves how to code proficiently in C?

Reading C books (including the C specification), Reading
books on software engineering (not C specific), Reading and
porting code (e.g., C code from other systems to the Amiga
or from other languages to C), writing C code, talking with
friends about C, Reading the C source code of a computer
game while playing it to find the tricks (how to play and
win), and giving C classes (my next C class starts this
thursday [the day after tomorrow] in Berlin; it's a real
C class [not a C++ class]).
 
N

notbob

What are the best methods you all have found for teaching yourselves
how to code proficiently in C?


There are good beginning tutorials online. Here's a few:
http://how-to.linuxcareer.com/c-development-on-linux-introduction
http://www.cprogramming.com/tutorial/c-tutorial.html
http://www.codingunit.com/the-history-of-the-c-language

Chew on these till you milk them dry, then look for some books. Read
the reviews on Amazon. If you have a B&N or good library, go there
and read 'em before buying. I once bought a C book that was highly
recommended and was not happy with it.

As another poster recommended, learn with a goal in mind. Excellent
advice. I've dabbled unsuccessfully in coding for yrs and never
really learned anything cuz I never had a reason. I've recently
discovered arduino hobby electronics, a hands-on fun end to my means.
It can be done in C. I think this stuff is a hoot and it got me back
into learning programming. Some examples:

http://ardrone.parrot.com/parrot-ar-drone/usa/

http://www.adafruit.com/products/170

http://www.adafruit.com/products/332 (watch the belt video)

http://tinyurl.com/7p886h5

This is all stuff that can be done with Arduino electronics and C
coding. I'll never get to the point of those amazing formation flying
q-copters, but it fires one's imagination and provides inspiration.

Oh! .....also learn code debugging as you go. Nothing is more
discouraging than debugging bad code, so learn how early.

notbob --geezer learning C way too late, but still trying ;)
 
B

Barry Schwarz

There are good beginning tutorials online. Here's a few:
http://how-to.linuxcareer.com/c-development-on-linux-introduction

This one has some really confusing examples (e.g., the discussion
regarding the ++ operator).

The discussion of pointers has major errors such as:

Next, we dereference ptoi, meaning we say "stop pointing to x and
start pointing to y".

and

when working with arrays, you don't have to use pointers, but it's
nice to do so, because operations will be faster,

and

Another important aspect is that any character array in C ends with
the null character

and it gets worse.
 
N

notbob

The discussion of pointers has major errors such as:

That's why I provided several sites. I've taken formal college C
programming classes twice and have yet to encounter a single learning
method that isn't flawed, somehow. If not blatant mistakes, then
outright omissions, like I will somehow absorb the correct approach
and/or code syntax by magic. One teacher used both C and C++ code as
if they were the same. Similar experiences with 2 books I've bought.
I've discovered having several sources for the same info usually
provides the answer, if only by consensus. ;)

nb
 
S

Stefan Ram

notbob said:
method that isn't flawed, somehow. If not blatant mistakes, then
outright omissions,

Some omissions are necessary in teaching, mistakes are not.
 
N

notbob

Some omissions are necessary in teaching, mistakes are not.

......and of course, in the interest of "teaching", you are going to
omit what those "necessary" omissions might be and why.

Balderdash!

nb
 
J

Jorgen Grahn

dunno, being a maintenance programmer on a nasty pile of code can be a
dispiriting experience. I wouldn't suggest i was necessarily a good
way to learn.

Still, IMO you need to work with (within) bad code to really learn C.
It teaches you how easy it is to end up in a mess, a few ways to get
there, and debugging/refactoring techniques.

And writing your own, fresh code can feel like a luxury afterwards ;-)

/Jorgen
 
J

JohnF

Fritz Wuehler said:

Ditto. That's the ticket. But conjuring up the functional specs
for an interesting, doable (in this case easily doable) project
is a skill in itself, in fact a job title in itself. Most entry
level books I've seen sacrifice the "interesting" in favor of
the "easily doable", which I guess is a necessary tradeoff.
Maybe there's some site with a collection of little learning
projects that's both, though I don't know of one. That would
be a nice idea in itself, probably largely language agnostic
(i.e., not C specific).
But working at a support role where you have to read lots of code
and fix it is even better than that and along with it,
you'll have it all.

That's a different mindset and a somewhat different skill.
Some people can do one and not the other: some just can't
seem to get going with nothing but a blank sheet of paper,
while others can't seem to dive into the middle of a pile
of existing code. Programmers need both skills in spades,
but you want to learn (as the op does) with writing your
own code, expressing your own thinking in your own style.
So, like "gwowen" first suggested, get yourself a project.
 
R

Rui Maciel

Nick said:
write lots of code.

the best way I found was already knowing anothe couple of programming
languages, but this probably doesn't help...

I would also add participating in public forums dedicated to the programming
language, such as comp.lang.c, and also forums dedicated to specific
platforms, such as comp.unix.programmer. Getting our hands dirty may be the
best learning experience that we can have, but being exposed to the
experiences that others had/are having will also contributes greatly to our
own progress.

Plus, when we stumble on a problem we might benefit from having a community
willing to help us out on it. Conversely, we may help others with their
problems, and in the process learn a bit more from it.

In short, we may do all our learning alone, but being a part of a community
dedicated to a specific subject also helps a lot.


Rui Maciel
 
J

Jorgen Grahn

Basically do it.

If you're sitting in a bedroom on your own, the most likely thing
you'll want to code is a game. So get graphics working as fast as you
can. It's harder now than it was to get a simple character-based
raster that can be used for moving space invaders round the screen.

It's still easy on Unix, where you have the curses library.

{{Unix bigot mode|
Unix in general makes it easier to write programs which are small and
have a simple interface, yet are useful. I haven't tried it, but I
imagine the threshold is much higher on Windows.}}

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top