Re: Code Comprehension
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Sun, 27 Aug 2006 08:09:06 +0200
ena8t8si@xxxxxxxxx writes:
Pascal Bourguignon wrote:
[...]
I know perfectly well that _in_ _C_, the type
char is a subtype of the type int.
You're confused. First, your statement is wrong;
second, it has nothing to do with the meaning of
'\0', which C defines to be of type int, and not of
type char. Read the ISO C Standard.
If you don't want to understand, just tell me, I won't insist.
When you have characters, use '\0' which explictely says Hello! I'm a character.
When you have integers, use 0 which explicitely says Hi! I'm an integer.
When you have pointers, use NULL which explicitely says See! I'm a pointer.
When you have booleans, use FALSE, false, NO, or any such properly
defined constant, which explicitely says Hey! I'm a boolean!
But if you want your code to be readable don't be so dumb to write
things like:
{
char ch=0;
int i=NULL;
void* p=NO;
bool b='\0';
}
The fact that the compiler generates the same code is irrelevant!
--
__Pascal Bourguignon__ http://www.informatimago.com/
CAUTION: The mass of this product contains the energy equivalent of
85 million tons of TNT per net ounce of weight.
.
- Follow-Ups:
- Re: Code Comprehension
- From: Chris Uppal
- Re: Code Comprehension
- References:
- Code Comprehension
- From: jj
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Logan Shaw
- Re: Code Comprehension
- From: Rob Thorpe
- Re: Code Comprehension
- From: Pascal Bourguignon
- Re: Code Comprehension
- From: Phlip
- Re: Code Comprehension
- From: Pascal Bourguignon
- Code Comprehension
- Prev by Date: Re: Code Comprehension
- Next by Date: Re: Sorting question
- Previous by thread: Re: Code Comprehension
- Next by thread: Re: Code Comprehension
- Index(es):
Relevant Pages
|