C

As a woman: A lady executive. An avid jogger, very healthy, and not too talkative. Is an good cook if you like spicy food. Unless you double check everything you say (through LINT) you can unleash her fierce temper. Her daughter C++ is still quite young and prone to tantrums, but it seems that she will grow up into a fine young woman of milder temper and more sophisticated character.

Shooting your foot: You shoot yourself in the foot.

- found on the net in Tallus Humor Archives (I think)



C - the choice of a generation

The C programming language was developed from the B language (I'm not kidding you1 ;-). The B language did not support types, which was a bit of a drawback. Now what made C such a great choice - mostly it's platform indepence and higher level of programming without loosing contact with the machine. C supports the constructs used most frequently in imperative programming - loops, branches, sequences - and the basic types such as integers, floating-point, pointers and structures.

Most of the official version of the language is based on the Kerningham & Richie version described in the "bible" of the language - "The C Programming Language". Later on the language was ANSIfied, and stick with this standard. Most compilers out there fully supports ANSI C apart from their own dialects.

One of the largest implementation of C is the UNIX operating system - almost all of the source for the system is written in C making it relatively easy to port the operating system. A free implementation with publicly available source is Linux.

The syntax of C is compact, some may say too compact for beginners - I, for one, disliked the language in the beginning. I found it too compact and unreadable since I was used to the babbling of Pascal. There is a running contest for the most unreadable code located at ().

Another thing about C is the power unleashed in pointers - a good understanding of pointers are essential to the successful use of C. Without pointers you get no benifits of C. C is much like working in assembler - if you understand the use of memory areas and pointers, you'll be good on your way to succeed.

The switch-statement

I have to make a remark about this, because I really dislike it - the switch statement - probably the most ridicules syntax I have seen - why spend so much code on case 1: and break; when the entire purpose of the switch statement is obvious - it only makes it easier to make hard-to-find bugs. And that is the worst about C/C++, bugs arise easily but are difficult to find.

Finally figured it out - of course, when you are used to Pascal, a bit of case-code would look like this:

case var of
 1: something;
 2: otherthing;
 3..8: lastthing;
else
 unknown;
end;

notice the 3..8, it means anything between 3 and eight. That is quite invalid in C, so each case must be listet with a fall-through:

switch (var)
{
	case 1: something(); break;
	case 2: otherthing();break;
	case 3: case 4: case 5: case 6: case 7: case 8: lastthing(); break;
	default: unknown(); break;
}


Back...





1Peter Hansen/Per Henriksen: Turbo C 2.0 (1. udg. 1. oplag 1989): Teknisk Forlag: s.15


Last updated 2001-08-22 FlushedSector