Article View: comp.sys.atari.st
Article #26329Re: sizeof("string")
From: jmg
Date: Wed, 15 Apr 1987 07:34
Date: Wed, 15 Apr 1987 07:34
45 lines
1740 bytes
1740 bytes
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!
Technical Details
Message-ID:
<468@cernvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mcvax!cernvax!jmgReferences:
<8704120143.AA11235@cory.Berkeley.EDU> <2006@ihuxz.ATT.COM>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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