Re: Another Understanding Pointers Question

From: Leor Zolman (leor_at_bdsoft.com)
Date: 05/11/04


Date: Tue, 11 May 2004 01:34:55 GMT

On Tue, 11 May 2004 01:56:17 +0100, Materialised <Materialised@privacy.net>
wrote:

>I have taken all the people who replied comments to heart, and I am glad
>for your feadback.
>What I dont understand is what is wrong with sizeof(char)? True char may
>be defined as 1 on most architectures. But does the way I have
>referenced it require extra CPU useage or something?
>
>Sorry if thats a dumb question..

Not dumb at all. The Standard spells it out as follows (6.5.3.4/3):

"When applied to an operand that has type char, unsigned char, or signed
char, (or a qualified version thereof) the result is 1."

So sizeof(char) is 1, period. Which makes writing it out a bit redundant,
that's all.
        -leor

-- 
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix  
C++ users: download BD Software's free STL Error Message Decryptor at:
   www.bdsoft.com/tools/stlfilt.html


Relevant Pages

  • Re: Question about unpacking a binary file: endian troubles
    ... > This may be a dumb question; I'm just getting into C language here. ... `char' is always zero or positive, ... include to declare it. ... > int fdi, n; ...
    (comp.lang.c)
  • Re: How would you use qsort to sort on a string
    ... breaksdown the problem. ... I think its a pretty dumb question myself, ... it was "how to do it without conditional statements ... sort_string (char *s) ...
    (comp.lang.c)
  • Re: Value of EOF
    ... >> I've wondered whether there are architectures where forcing char to ... >> be unsigned would adversely affect performance - if for example there ... Reference: Peer Protocols_. ...
    (comp.lang.c)
  • [PATCH 1/2] Create compat_sys_migrate_pages.
    ... This is needed on bigendian 64bit architectures. ... extern int compat_printk(const char *fmt, ...
    (Linux-Kernel)
  • Re: Adding to void *
    ... pointers violates a constraint. ... the "correct" behavior is to cast to char or similar, ... architectures, as I guess some could point out: ...
    (comp.lang.c)