Nice tutorial for Beginners

F

Frank

For beginners 25 years ago maybe, but not today. Lots of old K&R C.

I don't know which way I'd go on that. If it's K&R2, isn't that late
enough to begin a development that would not want to tackle differences
between C90 and C99 off the bat?

I guess the one thing I'd bring up is that you can comment with the double
slash now.
 
N

Nick Keighley

As the C language is the basic of all the languages ,

I think you'd find a fair number of people who'd argue *that* one.
here is the nice
tutorial from which you may start learning it C.

there are few good online tutorials for C. I believe Steve Summit
produced a good one. This one is very pretty.

In summary it is too old and too DOS oriented to be recomended. It is
not suitable for a beginner. I gave up skimming it around chapter 12.
It's a nice tutorial
in the pdf format which you can also download it for
free.http://www.ezdia.com/C_Tutorial/Content.do?id=736

It has a faintly old fashioned style to it. "if your disk is less than
800K..." "you cann't use more than 8 characters in an identifier" "
experienced C programmers tend not to use underscores" frequent
mention of Pascal.

After three or four examples they still
- have no return value from main
- use printf() without a prototype

"A general rule of thumb for modern compilers is that char is at least
8 bits, short is at least 16 bits, long is at least 32 bits,"

"As a consequence, you should use either short or long in preference
to int (despite
its heavy use in this tutorial), and should avoid double where
possible."

[if you shouldn't use int why are they using it?!]

section 5.1 use of K&R style function definitions. Use of functions
without a prototype in scope. This probably kills it as a reasonable
tutorial on modern systems.

#define WRONG(A) A*A*A /* Wrong macro for cube */
#define CUBE(A) (A)*(A)*(A) /* Right macro for cube */

could do with another set of brackets

"A string is a group of characters, usually letters of the alphabet."

pointers and strings stuff is a little confused (section 8.8)

chapter 9 we finally get standard headers!
# include "/sys/stdio.h"

use of <> includes depracated!

section 9.7 very bad advice on handling line terminators. Non-DOS
systems are described as "non-standard".
 
I

Ian Collins

Frank said:
I don't know which way I'd go on that. If it's K&R2, isn't that late
enough to begin a development that would not want to tackle differences
between C90 and C99 off the bat?

It's very old pre-standard K&R C.
 
N

Nick Keighley

noramally (and in this case too) "K&R C" means "K&R1 C". This tutorial
uses the uses the pre-ANSI format for function definitions.

square(number) /* This is the square function */
int number;
{
int numsq;
numsq = number * number; /* This produces the square */
sum += numsq;
}

IMHO this was the biggest mistake C ever made.

I don't know which way I'd go on that.  If it's K&R2, isn't that late
enough to begin a development that would not want to tackle differences
between C90 and C99 off the bat?

I guess the one thing I'd bring up is that you can comment with the double
slash now.

mixing definitions with statements? bool?
 
I

Ike Naar

square(number) /* This is the square function */
int number;
{
int numsq;
numsq = number * number; /* This produces the square */
sum += numsq;
}

What is "sum"? And why doesn't the function return an int?
IMHO this was the biggest mistake C ever made.

At least they fixed that.

The next biggest mistake was to name the assignment operator "=",
and the equality operator "==". And they'll never fix that :-(
 
N

Nick Keighley

What is "sum"?

my fault. I copied the function out of the tutorial (section 5.1) but
didn't copy:-

int sum; /* This is a global variable */

And why doesn't the function return an int?

they used implicit int return. They forgot the return statement.
At least they fixed that.

The next biggest mistake was to name the assignment operator "=",
and the equality operator "==". And they'll never fix that :-(

then there's the precedence of &. Thye thought about changing that but
thousands of lines of code already existed...
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top