hardcoded constants

Dave Jones djones at megatest.UUCP
Fri Dec 23 15:27:01 AEST 1988


>From article <77 at attibr.UUCP>, by vch at attibr.UUCP (Vincent C. Hatem):

> 
> Last I heard sizeof("/") == sizeof(char *) - which is almost never 2, and
> NEVER portable.
> 

First I heard sizeof("/") == 2 which is sometimes sizeof(char*), and
ALWAYS portable. 

On my machine, a 68020 based Sun3/60, sizeof(char*) seems to be either
four or seven, depending.

Don't feel bad.  I blew sizeof('\0') bigtime.


% cat foo.c
main()
{
  printf("%d %d\n", sizeof(char*), sizeof ("foobar"));
  exit(0);
}
% cc foo.c
% a.out
4 7 



More information about the Comp.lang.c mailing list