Malcolm McLean wrote:
Thanks for your help. I work as best I can with the *nix API in kandr2 and I
am interested in sockets. The most confusing thing seems to be pointers but
that's typical. I know if you wanted a static buffer you can simply use an
array. I'm not quite sure how to use malloc as a dynamic buffer but I will
try and find out. The thing with C is I know the basics but not the
/caveats/ of how to use the language. Such as malloc is intended for buffers
that you are not sure of what the size is going to be. All I know to do is
just jump in and do your best and if you hit a brick wall; ask for help. I
am beginning to undestand what "pass by value" actually means and it
involves pointer manipulation. But as is said "C wears well as one's
experience with it.." and so on.
Bill
C is possibly the worst language for "just jumping in". A language like Python
is designed to be fairly intuitive and has a gentle learning curve. You can
pick up the basics on Friday and write a working program on Saturday (unlikely
to be a *good* Python program but if it is short enough it will likely do what
you intend it to do). With C, there are a host of problems which are likely to
trip up beginners (out-of-bounds errors, buffer overflows, stray pointers,
memory leaks) which can't arise in a language like Python. Furthermore -- these
are not always problems that you encounter "like a brick wall". Sometimes they
are more like hidden booby traps which don't explode until after your program
is up and seemingly running. If you learn about pitfalls only as you become
aware of them then it is almost certain that your code is going to contain
bugs silently lurking in the background.
Having said all this -- if you are a hobbyist programmer and you are just
playing around then none of this really matters, and actually coding *is* a
good way to learn. So by all means - jump in. But, don't *just* jump in. I
would recommend dividing your time between coding and reading a good book. I
highly recommend King's book "Modern C Programming".