C examples and codes

T

Tsb

I have read about learning C programming language. Lots of them said
the best way to learn C is reading codes.

So where can I find codes and some examples?
 
R

Richard

Tsb said:
I have read about learning C programming language. Lots of them said
the best way to learn C is reading codes.

So where can I find codes and some examples?

The best resources by FAR are the Linux/Gnus source codes. Big dirty
applications with bugs to fix. You might not learn "Ansi C", but you
will learn real world Linux C in no time.. especially if you submit a
bug fix which is not done properly...
 
J

John Bode

I have read about learning C programming language. Lots of them said
the best way to learn C is reading codes.

So where can I find codes and some examples?

The *best* way to learn C is to find an authoritative reference such
as Kernighan & Ritchie's "The C Programming Language", 2nd ed., or
Harbison & Steele's "C: A Reference Manual", 5th ed (taken together,
those two should give you as solid a foundation in C as anything
else).

99% of the tutorials and examples on the Web are *crap*, and should be
avoided like the plague; they get basic concepts wrong, invoke
undefined behavior, and promote bad programming practice. There's a
lot of production code out there that isn't much better.
 
J

jacob navia

John said:
99% of the tutorials and examples on the Web are *crap*, and should be
avoided like the plague;

99% of people posting in Usenet say crap, and should be avoided like the
plague.
 
P

Philip Potter

jacob said:
99% of people posting in Usenet say crap, and should be avoided like the
plague.

But on Usenet, there's always someone watching with a copy of the
standard to hand. If there's crap, it's pointed out.
 
J

John Bode

99% of people posting in Usenet say crap, and should be avoided like the
plague.

Are you saying I'm wrong? I've yet to see a C tutorial on the Web
that didn't have fundamental mistakes.
 
J

jacob navia

Jalapeno said:
99% of all statistics in Usenet are made up.

Of course!

What bothers me is that before his message
I sent a message about my tutorial,
that has taken me years of work.

Before making such sweeping statements, Mr Bode could (maybe)
try to see the tutorials that aren't crap...
 
J

jacob navia

John said:
Are you saying I'm wrong? I've yet to see a C tutorial on the Web
that didn't have fundamental mistakes.

I sent a message (in this same thread) about the tutorial of
lcc-win, available from the web.

I thought you were referring to mine, so maybe I overreacted.

Give it a try. It is not perfect, as anything done by a
human, but it is not just crap.
 
R

Richard Heathfield

John Bode said:
Are you saying I'm wrong?

He didn't actually claim that you were wrong. And in fact as far as the 99%
goes, he's probably right - which makes a pleasant change for him, so
let's not spoil his moment of correctness, eh?

I've yet to see a C tutorial on the Web
that didn't have fundamental mistakes.

There are a couple that I know of that are not full of fundamental mistakes
- the Steve Summit one, and the one by Tom Torfs.

Their URLs are:

http://www.eskimo.com/~scs/cclass/
http://cprog.tomsweb.net/cintro.html

although Tom's keeps moving around for some reason. Anyway, those are the
last places I knew about. Whenever I discover that Tom's has moved, I
write down the new URL here:

http://www.cpax.org.uk/prg/portable/c/resources.php#WebTutorials
 
J

John Bode

I sent a message (in this same thread) about the tutorial of
lcc-win, available from the web.

I thought you were referring to mine, so maybe I overreacted.

Ah. I hadn't seen that message before posting mine. No, I wasn't
referring to yours; I haven't seen it yet. Of the ones I *have* seen,
though, the vast bulk are crap.
 
P

Philip Potter

jacob said:
Of course!

What bothers me is that before his message
I sent a message about my tutorial,
that has taken me years of work.

Before making such sweeping statements, Mr Bode could (maybe)
try to see the tutorials that aren't crap...

I was curious, so I followed your link. Since you advertised an
introduction to C, I clicked on "C tutorial". I got presented with a
list of adverts for books on amazon -- which presumably make you and
Friedrich Dominicus money -- but no C tutorial.

I found that you're selling a C tutorial in your shop. I'm certainly not
going to pay 30 EUR to review it for you. However I can already see that
it's not entirely a tutorial of standard C because it advertises
"Windows C Programming". Not that there's anything wrong with that, but
it's probably not appropriate to advertise it on this group.
 
S

Shadowman

Philip said:
I was curious, so I followed your link. Since you advertised an
introduction to C, I clicked on "C tutorial". I got presented with a
list of adverts for books on amazon -- which presumably make you and
Friedrich Dominicus money -- but no C tutorial.

I found that you're selling a C tutorial in your shop. I'm certainly not
going to pay 30 EUR to review it for you. However I can already see that
it's not entirely a tutorial of standard C because it advertises
"Windows C Programming". Not that there's anything wrong with that, but
it's probably not appropriate to advertise it on this group.
No, it's available for free, although a bit hard-to-find.

From the page advertising the books, you need to click on the "get me
to the downloads" button.
 
R

Richard

John Bode said:
Are you saying I'm wrong? I've yet to see a C tutorial on the Web
that didn't have fundamental mistakes.

I am saying your are wrong.

There are surely some mistakes. But that doesn't make them "crap".

Still, you are are most certainly in the right newsgroup.
 
J

jacob navia

Philip said:
I was curious, so I followed your link. Since you advertised an
introduction to C, I clicked on "C tutorial". I got presented with a
list of adverts for books on amazon -- which presumably make you and
Friedrich Dominicus money -- but no C tutorial.

You have to scroll down and press "take me to the downloads" button.
I found that you're selling a C tutorial in your shop.

This is a hardcopy version, the elec tronic version is free.
> I'm certainly not
going to pay 30 EUR to review it for you. However I can already see that
it's not entirely a tutorial of standard C because it advertises
"Windows C Programming". Not that there's anything wrong with that, but
it's probably not appropriate to advertise it on this group.

Look, it is a tutorial for C. Since "Standard C" doesn't RUN anywhere
(you need some specific compiler, some specific operating system,
some way of doing windowed output etc) it is a tutorial of
C in a certain context. The first part is about standard C,
the second about windows, and the third is about network programming.

The first part presents a fairly complete view of the language.
 
R

Richard

Philip Potter said:
I was curious, so I followed your link. Since you advertised an
introduction to C, I clicked on "C tutorial". I got presented with a
list of adverts for books on amazon -- which presumably make you and
Friedrich Dominicus money -- but no C tutorial.

You didn't look hard enough in your desire to have a knock at Jacob once more.
I found that you're selling a C tutorial in your shop. I'm certainly

And giving a free tutorial and compiler.
not going to pay 30 EUR to review it for you. However I can already

He didn't ask you to review it for him. He pointed it out to a nOOb who
wishes to learn C.
 
R

rosewater

jacob said:
You have to scroll down and press "take me to the downloads" button.


This is a hardcopy version, the elec tronic version is free.


Look, it is a tutorial for C. Since "Standard C" doesn't RUN anywhere
(you need some specific compiler, some specific operating system,
some way of doing windowed output etc) it is a tutorial of
C in a certain context. The first part is about standard C,
the second about windows, and the third is about network programming.

The first part presents a fairly complete view of the language.

Which language? C or lcc-win32? I think we can all guess how
misleading the name "C tutorial" will be for the sort of garbage that
Navia is wont to produce. Non-portable Windows-specific crap.
 
R

Richard Heathfield

jacob navia said:

Look, it is a tutorial for C.

Have you fixed the problems yet that we found the last time we looked? All
of them?

If so, I guess it's time to find the next bunch of problems. And if not,
why not?
 
P

Philip Potter

jacob said:
You have to scroll down and press "take me to the downloads" button.


This is a hardcopy version, the elec tronic version is free.

....but conveniently for you, sends more people past your
revenue-generating amazon links.
Look, it is a tutorial for C. Since "Standard C" doesn't RUN anywhere
(you need some specific compiler, some specific operating system,
some way of doing windowed output etc) it is a tutorial of
C in a certain context.

This is sheer nonsense. Standard C runs anywhere there is a standard C
implementation. (And you shouldn't write programs which require
"windowed output").
The first part is about standard C,
the second about windows, and the third is about network programming.

The first part presents a fairly complete view of the language.

Here are a few bits I've picked out:

p2: "A program in C is written in one or several text files called
source modules. Each of those modules is composed of functions, i.e.
smaller pieces of code that accomplish some task, and data, i.e.
variables or tables that are initialized before the program starts."

That defines static data, but what about automatic variables and
dynamically allocated data?

p2: "Lisp and scheme, two list oriented languages featured automatic
garbage collection since several decades."

This should be "Lisp and scheme, two list oriented languages, have
featured automatic garbage collection for several decades." (For a
non-native speaker, your english is very good, but your usage of "since"
here is wrong, and you frequently use this incorrect idiom. This will be
the last spelling/grammar criticism from me, since it is offtopic.)

On p18, your example of a typecast is in a position where the cast is
unnecessary:
float f = 67.8f;
double d = (double)f;

On p19 your description of the size of arithmetic types is mostly wrong.
It is true that char is 1 byte (by definition) but it is not true that
short must be 2 bytes, int must be 4, long must be 4 or long long must be 8.

p21: "Machine addresses are just integers, of course. For instance, if
you have a machine with 128MB of memory, you have 134 217 728 memory
locations."

I don't know what you're talking about, but it's not standard C. Machine
addresses are not necessarily "just integers".

p54:
"1.13.10 union.
You can store several values in a single memory location or a group of
memory locations with the proviso that they can’t be accessed at the
same time of course. This allows you to reduce the memory requirements
of a structure, or to interpret a sequence of bits in a different fashion.
For a detailed discussion see “Unions” on page 107."

This isn't very clear. It sounds like I can store multiple variables in
a union simultaneously, provided I don't access them simultaneously.

p57:
"1.13.19 unsigned.
Integer types (long long, long, int, short and char) have the most
significant bit reserved for the sign bit. This declaration tells the
compiler to ignore the sign bit and use the values from zero the 2^n for
the values of that type. For instance, a signed short goes from –32767
to 32767, an unsigned short goes from zero to 65535 (2^16). See the
standard include file <stdint.h> for the ranges of signed and unsigned
integer types."

Why even mention a sign bit? Also while that is the minimum range for a
signed short, it may be larger (and it wouldn't surprise me if it is
larger on lcc-win32!)

p123: C does not require ASCII. You fail to communicate this and
actively mislead your readers by saying the ordering used by strcmp is
based on the ASCII character set.

p134: alloca() is not standard C, but you do not state this. AFAIK
_msize() and _expand are not either.

p138: Are you really advocating writing programs which do not free() all
that they malloc()?

p146: This is a poor hash function, and you do not explain sufficiently
well the importance of a good hash function.

p182: IEEE 754 floating point is not required by the standard.

p190: QFLT_EPSILON is not part of the standard, though it looks like you
state that it is.

Overall, the typesetting is dreadful: on p3, "argument-list" should not
wrap a line. When you introduce main, you italicise it, but when you
introduce printf, you put it in double quotes. On p13, the line numbers
in the second example look like they're part of the code (and cause
syntax errors!) On p18 you have a code example in a proportional font.
On top of all this, there is no Chapter 2!

This is after a quick skim, I haven't read most of it. But what I have
read already means I wouldn't recommend this guide to anyone as an
introduction to standard C. In some places, you take care to inform the
reader what is standard and what is lcc-win32 specific, but in other
places you do not. And your explanations and definitions are sloppy, but
an introduction to C must be strict and careful with its use of words.
 

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,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top