Xref: utzoo comp.lang.c:9373 comp.arch:4358 Path: utzoo!mnetor!uunet!husc6!bbn!rochester!udel!gatech!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c,comp.arch Subject: {char foo[]="This is a test."; printf("%d\n",sizeof foo);} Message-ID: <788@xyzzy.UUCP> Date: 15 Apr 88 15:53:39 GMT References: <11702@brl-adm.ARPA> <243@eagle_snax.UUCP> <2245@geac.UUCP> <8646@eleazar.Dartmouth.EDU> <877@cresswell.quintus.UUCP> <23396@bbn.COM> Organization: Data General, RTP NC. Lines: 37 > emiller@bbn.com (ethan miller) >> ok@quintus.UUCP (Richard A. O'Keefe) >>> major@eleazar.Dartmouth.EDU (Lou Major) >>> char foo[]="This is a test."; >>> sizeof (foo) == sizeof (char *) >>Wrong. The answer *is* 16. [...assuming sizeof(char)==1, but let's >>not get into that...] This is one of the few cases where >>foo and &(foo[0]) are different. > What did you try? _I_ just tried printing foo and &(foo[0]), and > they are the same. BTW, I also tried sizeof (foo), and it is 16. From the context, I assumed that by "This is one of the few cases where foo and &foo[0] are different", Richard meant "(sizeof foo) and (sizeof (&foo[0])) may give different results", which is quite correct. For example: $ cat >test.c <<. char foo[]="This is a test."; main(){} . $ cc -g test.c $ dbx a.out Scanning executable file... (dbx) whatis foo char foo[16]; (dbx) print (sizeof foo) 16 (dbx) print (sizeof &foo[0]) 4 (dbx) quit $ -- If the argument to .TH contains any blanks and is not enclosed by double quotes, there will be dird-dropping-like things on the output. --- Unix User's Manual, MAN(7) entry, BUGS -- Wayne Throop !mcnc!rti!xyzzy!throopw