🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #26295

Re: "file selector" blues, Megamax bug

#26295
From: wheels
Date: Tue, 14 Apr 1987 13:08
38 lines
1618 bytes
In article <1934@ihuxy.ATT.COM>, nowlin@ihuxy.ATT.COM (Jerry Nowlin) writes:
> In article <639@batcomputer.tn.cornell.edu>, braner@batcomputer.tn.cornell.edu (braner) writes:
> > 	sizeof("a string constant") always yields 4.
> > - Moshe Braner
> 
> It's almost funny but some of the 3B compilers also return 4 for this
> operation and trying to solve the bug it introduced into our code was the
> cause of much wailing and gnashing of teeth.  If you want the length of a
> string use strlen().  Personally I think it's a bug if sizeof("string")
> doesn't return the size of (char *).
> Jerry Nowlin

Well, according to the C gurus here at MKS, this is what should happen:

{
	int a;

	a = sizeof("hello");	/* should produce 6 (5 chars + '\0') */
}

{
	int a;
	char s[] = "hello";

	a = sizeof(s);		/* should also produce 6 */
}

{
	int a;
	char s[25] = "hello";

	a = sizeof(s);		/* should produce 25 */
}

Gerry
-- 
Gerry Wheeler                  {seismo,decvax,ihnp4}!watmath!mks!wheels
Mortice Kern Systems Inc.
Technical Details
Message-ID: <250@mks.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!mks!wheels
References: <639@batcomputer.tn.cornell.edu> <1934@ihuxy.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!watnot!watmath!mks!wheels
From: wheels@mks.UUCP
Newsgroups: comp.sys.atari.st
Subject: Re: "file selector" blues, Megamax bug
Message-ID: <250@mks.UUCP>
Date: Tue, 14-Apr-87 08:08:37 EST
Article-I.D.: mks.250
Posted: Tue Apr 14 08:08:37 1987
Date-Received: Wed, 15-Apr-87 05:09:00 EST
References: <639@batcomputer.tn.cornell.edu> <1934@ihuxy.ATT.COM>
Organization: Mortice Kern Systems, Waterloo, Ont.
Lines: 38
Keywords: user-friendly C sizeof
Summary: My gurus say...