Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mcvax!cernvax!jmg From: jmg@cernvax.UUCP Newsgroups: comp.sys.atari.st Subject: Re: sizeof("string") Message-ID: <468@cernvax.UUCP> Date: Wed, 15-Apr-87 02:34:44 EST Article-I.D.: cernvax.468 Posted: Wed Apr 15 02:34:44 1987 Date-Received: Fri, 17-Apr-87 06:15:41 EST References: <8704120143.AA11235@cory.Berkeley.EDU> <2006@ihuxz.ATT.COM> Reply-To: jmg@cernvax.UUCP () Organization: CERN European Laboratory for Particle Physics, CH-1211 Geneva, Switzerland Lines: 45 In article <2006@ihuxz.ATT.COM> burris@ihuxz.ATT.COM (Burris) writes: > >The first response was correct. That's why there's a strlen() function. >Now if it were as follows: > >char string[ 20 ]; >char *strpt = "hello"; > >main() >{ > printf( "%d\n", sizeof( string ) ); > printf( "%d\n", sizeof( strpt ) ); > printf( "%d\n", sizeof( "hello" ) ); >} > >the result would be: > >20 >4 >4 As the originator of all of this C(ontroversy) I thought that I ought to see what happens on our BSD4.2 system. The output of the test program: 20 4 6 The moral is clear: either say what the test program DID produce (on system xyz with compiler pqr) or risk dropping a clanger. Moshe did suggest to me a trick which made sizeof work. I forget what it was. Two further precisions on Megamax: 1. It is %* which is not accepted in printf statements. 2. Megamax does not like #define statements stuck just anywhere. It appears that they must be at the start of the text (I am not sure of the exact restrictions, but a perfectly valid gnuplot #define of a symbol is rejected. Also, no getenv for megamax!