|
|
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
|
|