C programming prerequisites

D

David Delony

I've hacked on shell and Perl and now I want to get seriously into
C. I got bogged down in K & R, but I realized that I need to know more
about the low-level computing stuff. I'd like some pointers (no pun
intended) to further information.
 
U

user923005

I've hacked on shell and Perl and now I want to get seriously into
C. I got bogged down in K & R, but I realized that I need to know more
about the low-level computing stuff. I'd like some pointers (no pun
intended) to further information.

C-FAQ:
http://c-faq.com/

Tutorials from the horse's mouth:
http://www.lysator.liu.se/c/bwk-tutor.html
http://cm.bell-labs.com/cm/cs/who/dmr/ctut.pdf

Tutorials from Steve Summit:
http://www.eskimo.com/~scs/cclass/
http://www.eskimo.com/~scs/cclass/notes/top.html

Tom Torf's Tutorial:
http://cprog.tomsweb.net/cintro.html

After reading the tutorials and trying out the exercises in them, read
K&R2 again.
 
S

strangerdream

Tutorials from the horse's mouth:
<snip>
http://cm.bell-labs.com/cm/cs/who/dmr/ctut.pdf

I found something strange in the above tutorial:

<Quote from ctut.pdf>
25. Assignment Operators
An unusual feature of C is that the normal binary operators like '+',
'-', etc. can be combined with
the assignment operator '=' to form new assignment operators. For
example,
x =- 10;
uses the assignment operator '=-' to decrement x by 10, and
x =& 0177
forms the AND of x and 0177. This convention is a useful notational
shortcut, particularly if x is a complicated
expression. The classic example is summing an array:
for( sum=i=0; i<n; i++ )
C Tutorial - 23 -
sum =+ array;
But the spaces around the operator are critical! For instance,
x = -10;
sets x to -10, while
x =- 10;
subtracts 10 from x. When no space is present,
x=-10;
also decreases x by 10.
</Quote from ctut.pdf>

As far as I know,
x = -10;
x =- 10;
are equivalent. And for decrement, we use -= operator(not =-).
Was this something which was only in previous C standard or only in
K&R C?
 
R

Richard Heathfield

(e-mail address removed) said:
<snip>
http://cm.bell-labs.com/cm/cs/who/dmr/ctut.pdf

I found something strange in the above tutorial:

Hardly surprising - it's ancient history, and advertised as such. I
cannot see why user923005 is recommending it so highly to a newbie. It
is a very important document, yes - but important to whom? If you're
interested in learning C, Just Don't Go There. If you're interested in
the /history/ of C, however, then yes, by all means lap it up.
 
K

Keith Thompson

Tutorials from the horse's mouth:
<snip>
http://cm.bell-labs.com/cm/cs/who/dmr/ctut.pdf

I found something strange in the above tutorial:

<Quote from ctut.pdf>
25. Assignment Operators
An unusual feature of C is that the normal binary operators like '+',
'-', etc. can be combined with
the assignment operator '=' to form new assignment operators. For
example,
x =- 10;
uses the assignment operator '=-' to decrement x by 10, and
x =& 0177
forms the AND of x and 0177. [...]
As far as I know,
x = -10;
x =- 10;
are equivalent. And for decrement, we use -= operator(not =-).
Was this something which was only in previous C standard or only in
K&R C?

That's a *very* old tutorial, probably from the mid-1970s. The
language changed substantially even between then an K&R1. Yes, very
old versions of the language used "=-" where the modern language uses
"-=". It's historically fascinating, but not a good way to learn the
language as it exists now.

Some interesting oddities:

Here's the first code sample:

main( ) {
printf("hello, world");
}

See what's missing? I mean apart from "#include <stdio.h>", and
"int", and "return 0;"? There's no "\n" in the string literal.

No unsigned, no short, no long.

"Variable names have one to eight characters ..."

The language had octal constants, but no hexadecimal constants
(perhaps the PDP-11 influence).

getchar() returned '\0', not EOF, on reaching end-of-file.

Initializations didn't use "=":
int x 0;

Macros, but no function-like macros.

A suggested use of "goto" is for a long loop, where while(1) "would be
too extended":

mainloop:
...
goto mainloop;
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top