Journal Articles

CVu Journal Vol 12, #1 - Jan 2000 + Letters to the Editor
Browse in : All > Journals > CVu > 121 (30)
All > Journal Columns > LettersEditor (132)
Any of these categories - All of these categories

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: The Wall

Author: Administrator

Date: 08 January 2000 13:15:34 +00:00 or Sat, 08 January 2000 13:15:34 +00:00

Summary: 

Body: 

Corrections

Dear Francis,

You correctly pulled me up on the cast of realloc in the checkISBN2() and checkISBN3()routines referred to in C Vu 11.6 on page 29. I followed examples from published code and K+R 2nd Edition. However, after sending the ISBN code to you, I found the webpage for the book with updates (See http://cm.bell-labs.com/cs/cbook/2ediffs.html). Here there is an update that gives the same advice. I think some of the problems arose from using C++ compilers to compile code that was essentially C. They flag the lack of casting as a problem.

I prefer to leave the sizeof(char) in the call to realloc event though it will be optimised at compile time. If I ever convert the program to use UNICODE then replacing char with TCHAR will have the desired effect. It also happens to be one of the programming idioms which I use and it didn't seem worth making an exception for char - Buffersize = (number of items) * (sizeof(item)).

Your preferred rewrite of removeDashes appears to have a couple of bugs in it. In the while() construct == should be replaced with = otherwise no changes are actually made and sourcestring is returned. If this change is made then the pre-increment of j should be replaced with a post-increment otherwise the first character may be truncated. Also, give that we are modifying the passed value (sourcestring) is there any advantage in returning the string rather than a void? Were the errors deliberate?

Catriona O'Connell

If you are contemplating changing a type (char to wchar_t) rather a lot of change will have to take place so I remain unconvinced that any great benefit derives from the use of sizeof(char).

Yes, I was careless when defining my RemoveDashes function. I think you were the only one to notice the pre-increment error, which was deliberate though the == instead of = was not.

Notes: 

More fields may be available via dynamicdata ..