Why quotes are important, or, the importance of correctness

In the lecture today we covered arrays (and pointers) in C. About time too I thought. By way of an example the prepackaged lecture slides from Hanly and Koffman's C Program Design for Engineers, 2nd Ed showed how to use a character array as a string:
char b[] = ``Ned Flanders";
... is stored in memory as ...
`N' `e' `d' ` ` `F` `l' `a' `n' `d' `e' `r' `s' `\\0'
How many of you would expect that an example provided in a textbook on the C language would be legal code in C? My lecturer didn't appear to think so, which I think is outrageous and depressing at the same time. How are my fellow students supposed to learn the language when the examples presented are wrong? I've learnt a few things over the years when presenting information for others or teaching an SGR class. One of those things is that your examples must be correct --- in a language class, you must be able to compile the example! Five slides further on was a multi-dimensional char array example with not a single correct element. Folks, if you're going to display character constants in C, use the single quote or apostrophe ('). Using a "backtick" or ` character will not work. At all. Ever. If you are a unix sysadmin or perl programmer, you'll know the importance of the backtick. Back when I was a sysadmin (before I joined Sun) I used to read the book reviews on www.perl.org. I remember quite vividly a reviewer shredding what was otherwise a decent book because the font used for printing did not have a correct backtick glyph: at least half of the example code looked wrong on the page and was useless as a teaching or reference example.
Comments:

A few years ago I was in a group of students working on a project for a parallel programming class. The team was made up of a friend of mine, with about 10 years of on the job C experience who at the age of 52 came back to finish his CS degree, a senior in the CS department with no C experience, and myself. During the project, the guy with C experience, and myself, tried to teach the other one C as we went along working on a parallel sorting algo that was the premise of a research paper that our prof was just getting published as he had finally finished the paper that year.

One late night session we hit a snag as we got stuck on something causing us to sit back and reevaluate our plan. During that time, the guy with no C experience flat out told us that C was a "archaic language that was completely worthless in today’s world". Needless to say, he was turned down at a few job interviews when they found out he didn't know C and what he thought of C. Shame people are like that. But I guess it goes back towards your book & lecturer in that some people don't consider it relevant anymore to worry about the correctness of things like examples. Then again, I don't know where I would be today if I hadn't learned C over 10 years ago as a freshmen in high school. Hrm, people are crazy today I think.

Posted by Jeff on April 13, 2005 at 08:32 PM EST #

this is a very good page it helps alot of people like children

Posted by guest on April 02, 2008 at 11:44 PM EST #

Post a Comment:
Comments are closed for this entry.
About

I work at Oracle in the Solaris group. The opinions expressed here are entirely my own, and neither Oracle nor any other party necessarily agrees with them.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today