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;