comp.lang.c
[Top] [All Lists]

Re: CERT C Secure Coding Standard - last call for reviewers

Subject: Re: CERT C Secure Coding Standard - last call for reviewers
From: Martin
Date: Mon, 31 Mar 2008 16:30:27 +0100
Newsgroups: comp.lang.c


On Mon, 31 Mar 2008 04:10:43 +0100, Richard Heathfield wrote:
[...] Worse still, the name is misleading -
char * is not a synonym for string in C,
and to suggest (via the typedef) that it is,
is a disservice to the code reader.

I agree with you, but K&R2 Section 6.7 (Typedef) contains this:

   Similarly, the declaration

      typedef char *String;

makes String a synonym for char * or character pointer, which may then be used in declarations and casts:

      String p, lineptr[MAXLINES, alloc(int);
      int strcmp(String, String);
      p = (String) malloc(100);

My point being, that K&R2 is regarded by many as one of the C language's premier text books, and there we have it showing String as a synonym for char *. (Yes, I know the casting of malloc in K&R2's example is ill-advised.)

--
Martin


<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy