Subj : Re: Old C-program To : borland.public.cpp.borlandcpp From : Ed Mulroy Date : Tue Oct 11 2005 08:12 am Before the 1986 provisional C standard many compilers used C as taught in version 1 of the K&R book. It used this for NULL, #define NULL ((char *)0) The pre-1986 compilers normally did little type checking. Later compilers are more strict. The cast in this line: if ((char *) bentry == NULL ) is used to allow comparing the pointer to NULL when the pointer is not a char* type but NULL is a char* type. Compilers which conform to ANSI C, C as used since 1986 use #define NULL 0 and with them it is valid for any pointer type to be compared to zero. .. Ed > Vladimir Grigoriev wrote in message > news:434b8037@newsgroups.borland.com... > > I get an old-style C program and cannot understand some code. > Here it is. > > typedef struct BlockEntry > { > struct BlockEntry * next; > char name[4]; > unsigned long key; > int lock; > } BEntry; > > > int SomeFunction( bentry ) > BEntry * bentry; > { > unsigned long key; > > if ((char *) bentry == NULL ) > key = ONE_CONSTANT; > else > key = ANOTHER_CONSTANT; > > /* some code that I have skipped */ > > bentry->key = key; > > return 0; > } > > I cannot understand the following code > if ((char *) bentry == NULL ) > What did a programmer want to say? > Is the value of (char *)bentry is different form the value of bentry? .