sizeof "string"

W Stevens stevens at inuxh.UUCP
Tue Jan 31 23:39:12 AEST 1984


On our system (Vax 11/780 running UNIX 5.0, a.k.a. System V), the
program:

main()
{
	printf("size of \"Hello world!\" is %d\n",
	 sizeof("Hello world!"));
	exit(0);
}

prints the value 13.  This agrees with K&R page 181: "A string has type
'array of characters' and storage class static ... and is initialized
with the given characters."

--
Scott Stevens
AT&T Consumer Products Laboratories
Indianapolis, Indiana, USA
UUCP: inuxh!stevens

The difficult didn't get done yesterday, so the impossible will have to wait.



More information about the Comp.lang.c mailing list