Expert C Programming

(Jeff_L) #1

and our own favorite:


033 linker attempting to "duct tape" this "gerbil" of a


program


maybe that's why the linker is also called the binder...


These (possibly apocryphal) messages can be appreciated here as an in joke by an audience
of computer programmers. However, only use humor appropriately. One programmer (not
at Sun) coded a message into a networking driver that said "Bad bcb: we're in big trouble
now." It was the default case in a switch statement that, according to the protocol manual,
would never occur.


Naturally, it did occur; but not until the system was in production use in the field. The
customer site that got the message had a dozen or so mainframes attended round-the-clock
by operators. All console messages were printed and operators were expected to sign the log
confirming that the messages were read.


When this one came out, they called their supervisor, at 6 a.m., who promptly called the
vendor 's programmer at 3 a.m. Pacific Time. The supervisor explained that, because their
processing environment was crucial to staying in business, the operators had to take all such
messages very seriously, so what did this one mean?


Note that the message wasn't profane, and it told the programmer what went wrong. The
problem was that it needlessly alarmed the customer. An immediate new release was made
with a single change. The message became:


"buffer control block 35 checksum failed."


"packet rejected - inform support - not urgent."


Two lines is quite acceptable for a rare message like this.


Keep messages informative, non-inflammatory, and try to avoid unprofessional language
such as profanity, colloquialisms, humor, or even exaggerations. Especially when it will
save you being called out at 3 a.m.


Here's how a dynamic array can be effected in C. Fasten your seat belt; this may be a bumpy ride. The
basic idea is to use the malloc() (memory allocation) library call to obtain a pointer to a large chunk
of memory. Then reference it like an array, using the fact that a subscripted array decays to a pointer
plus offset.


#include <stdlib.h>


#include <stdio.h>


...


int size;


char *dynamic;

Free download pdf