From: fgd3@nifty.UUCP (Fabbian G. Dufoe, III)
Newsgroups: comp.sys.amiga.programmer,comp.sys.amiga.introduction
Subject: Re: How should I learn C?
Date: 29 Dec 92 12:15:03 EST
Distribution: world
Organization: Fabbian G. Dufoe, III

In article <78849@hydra.gatech.EDU> gt6758b@prism.gatech.EDU (Michael Maverick Kopack) writes:
>Could somebody please tell me how I should go about trying to learn C? I've

   There is no easy way to learn C.  The best starting point remains "The C
Programming Language" by Kernighan and Ritchie.  You'll encounter many
references to it as "K&R".  Sometimes you'll see the second edition called
"K&R2" to distinguish it from its predecessor.  Get K&R and work through
each exercise as you read it from cover to cover.  That will give you a
basic understanding of how C works.  Be prepared for some hard work.  You
don't pick up C overnight.

>gotten SAS/C 6.1, but really don't understand what I'm doing with it. My
>programming experience has been limited to PASCAL and BASIC and LISP. Heck,
>they don't even teach C here at GT!  I co-op with a government research center
>and they have taught me a little, but I'm having a really big problem 
>understanding the stuff with pointers.

   Everybody has trouble with pointers in C.  Once you understand it,
though, you will appreciate its power and convenience.  C's pointer notation
is especially confusing for Pascal programmers because both use the "->"
operator but the meaning is different in each language.

>I have been reading through a book called "C as a second language for PASCAL
>programmers" and have the most recent copy of the CManual disks in the Fish

   I'm not familiar with "C as a Second Language for Pascal Programmers" but
I don't think you will find any shortcuts to learning C.

>collection printed out. Are there any resources I could use that would give
>me a good, solid understanding of C.... I don't care about being able to do all
>the wiz-bang graphics and such yet, I just want to be able to write a few
>useful programs in C for my Amiga!

   K&R.  See above.

   Learning to program the Amiga in C is even harder than learning to
program in C.  Start by learning C.  Learn to write programs that use
standard input and standard output.  Stick with C's standard library
functions.  Once you've mastered that, you can start branching out to the
Amiga.lib functions.  There's just too much material to handle it all at
once.

>There are a lot of things about C that I find very frustrating after comming
>from a decent course in Pascal. For one is the way that Arrays are handled.
>I like being able to do stuff like    array [6..26] of int whereas in C you
>get forced into calling the indeces 0-19. I also HATE that there are no true 
>pass by reference parameters! 

   If you want to learn C the first thing you have to do is accept it as it
is.  It doesn't do any good to complain about its deficiencies with respect
to other languages.  It doesn't matter that you wish C had the same features
as Pascal--it doesn't.  Don't waste energy worrying about such things.

>It seems that C pretty much took Pascal and threw all the rules out the window!
>I can't imbed functions so other procedures can't see them (scoping rules),

   In C you group those functions in a separate source file and declare the
ones which are to be private as "static".  Nothing outside the source file
in which it is declared can see a static variable or function.

   Everything you need to write good programs is in C, you just have to
learn how a different language works.

>I have to use global variables a lot (taught as a no-no at GT) and it just
>seems like C is TOO flexible! How do you guys get anything done when there are
>about 500 different ways to do it?

   Don't use global variables!  Learn to pass arguments.  You can pass
arguments by reference by simply passing a pointer to the variable.

   I might help if you understand one of the things that makes C different
from other programming languages.  C is a high level language for doing the
kind of things you normally do in assembly language.  People write programs
in assembly language because they want to do things that other languages
won't let them do.  C gives you that kind of power within a high level
interface that insulates you from certain hardware differences.  Don't look
for it to be another high level applications programming language.

--Fabbian G. Dufoe, III
   350 Ling-A-Mor Terrace South   | GEnie:    F.DUFOE3
   St. Petersburg, Florida  33705 | internet: fgd3%nifty@tct.com
   813-823-2350                   | uucp:     ...tct!deep6!nifty!fgd3

Newsgroups: comp.sys.amiga.programmer