www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/29/10:38:41

From: jstacey AT plato DOT wadham DOT ox DOT ac DOT uk (J-P)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Weird : Segmentation fault on fwrite :(
Date: 29 Apr 2000 15:47:46 +0100
Organization: Wadham College Oxford
Lines: 33
Message-ID: <8eesmi$c8g$1@plato.wadham.ox.ac.uk>
References: <956963090 DOT 719428 AT romulus DOT infonie DOT fr> <957001855 DOT 943830 AT romulus DOT infonie DOT fr> <8eef1d$ai7$1 AT plato DOT wadham DOT ox DOT ac DOT uk> <390adf87 DOT 104978688 AT news DOT freeserve DOT net>
NNTP-Posting-Host: plato.wadham.ox.ac.uk
X-Trace: news.ox.ac.uk 957019667 17075 163.1.164.74 (29 Apr 2000 14:47:47 GMT)
X-Complaints-To: newsmaster AT ox DOT ac DOT uk
NNTP-Posting-Date: 29 Apr 2000 14:47:47 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>J-P wrote:
>
>>	If char arrayname[80] is an array of 80 char,
>>	 . arrayname is (equivalent to) a pointer to the first char
>>	 . &arrayname is a pointer to a pointer to the first char
>
>No.

Ah. This is the relevant bit from K&R. Appendix A7.3 - Postfix
Expressions (subsequently "PE"s).

	A7.3.1 Array References

	A PE followed by an E in square brackets { i.e. PE[E] - jps } is a
	postfix expression denoting a subscripted array reference. One of
	the two expressions must have type "pointer to T", where T is some
	type, and the other must have integral type. 

So in my example, "arrayname" /is/ of type "pointer to char". Isn't it?
According to K&R, at least, there seems no ambiguity.

Perhaps the printf family of functions is clever and recognises pointer to
pointer, and the standard libraries allow gcc to compile equivalent
executables. Any idea? Have I interpreted K&R wrong, do K&R slip up at
this point, or is gcc/printf doing something wiley?

If anyone wants to suggest a more relevant newsgroup, I'd happily follow
this there, trn willing.

J-P
-- 
Sacred Message // adopted by Japanese family // living next to NASA //
obscene orange flower // chance meeting with Ted Bundy 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019