Re: unexpected result



jaysome said:

<snip>

<dialogue>
Son: "Dad, I want to learn how to program in C."

Dad: "Son, although I admire your goal, I've been reading a lot in CLC
lately, and based on what they're saying in there, I'm pretty shocked
about how a simple, honest mistake you might make could lead to
formatting my hard drive. So I have to say no on this one."

In 1989, I was learning C. The guy sitting next to me was learning C too. He
omitted to provide sufficient storage for a string. (He was just one byte
short.) When the program ran, he saw pretty much what he expected to see,
just general student-program output, you know the stuff - and then, at the
bottom there, it said something like:

"Do you really want to format C: (Y/N)?"

He was *very* fortunate. The result of this particular instance of undefined
behaviour appears to have been a jump into "the system" - and if it had
jumped just a bit further, he could well have had his hard drive formatted
without being asked. No, I'm not making this up.

The following year, I'd managed to find a job as a C programmer. A colleague
of mine had clearly been on the Intermediate C course and the Advanced C
course, but had unaccountably failed to turn up for the Basic C course. He
made *exactly the same error* (i.e. an array that was one byte too short
for the string being stored there), and this time it did actually trash the
machine, to the extent that it wouldn't even boot until we started feeding
diagnostic diskettes into it.

Your "Dad" character is quite right. Leave C well alone unless you're
prepared to spend the time and effort it takes to get it right.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: Repost - Breaking In/gg
    ... Because your poem?s narrator is focused on the boy, ... both seem to set the tone of the relationship between father ... Though I suppose a "ritual Dad" would help his son with this ...
    (rec.arts.poems)
  • Liverpool joke
    ... SON "Dad, my mates in school told me that Liverpool won the ... DAD "Yes son, it's true, but they were dead lucky son, all the way ... SON "Jesus Christ - so Liverpool beat the English Champions elect too" ... against the best defence in Europe" ...
    (rec.sport.soccer)
  • Re: Liverpool joke
    ... SON "Dad, my mates in school told me that Liverpool won the ... DAD "Yes son, it's true, but they were dead lucky son, all the way ... SON "Jesus Christ - so Liverpool beat the English Champions elect too" ... against the best defence in Europe" ...
    (rec.sport.soccer)
  • Raising boys that feminists will hate: Part Five
    ... I suggest rebellion-unless you're cool with your son acting like JLo. ... Mom and dad, ... give the female chauvinist pigs any ground by pitting one form of masculinity ... Finally, parent, can you imagine the angst when Hollywood and the multitudinous, ...
    (soc.men)
  • Re: unexpected result
    ... Dad: "Son, although I admire your goal, I've been reading a lot in CLC ... The guy sitting next to me was learning C too. ... and it doesnt cause your hard disk to get erased. ...
    (comp.lang.c)