delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/29/09:08:55

From: dontmailme AT iname DOT com (Steamer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Weird : Segmentation fault on fwrite :(
Date: Sat, 29 Apr 2000 13:11:48 GMT
Organization: always disorganized
Lines: 26
Message-ID: <390adf87.104978688@news.freeserve.net>
References: <956963090 DOT 719428 AT romulus DOT infonie DOT fr> <20000429101940 DOT A22474 AT chance DOT cz> <957001855 DOT 943830 AT romulus DOT infonie DOT fr> <8eef1d$ai7$1 AT plato DOT wadham DOT ox DOT ac DOT uk>
NNTP-Posting-Host: modem-116.tennessee.dialup.pol.co.uk
X-Trace: news5.svr.pol.co.uk 957013909 5419 62.137.93.116 (29 Apr 2000 13:11:49 GMT)
NNTP-Posting-Date: 29 Apr 2000 13:11:49 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
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. Try compiling HPMAN's example with the & and then without, and you
will get an identical .exe.

Here, arrayname is an array, and will be implicitly converted to a
pointer to (its first) char in most contexts.

Meanwhile, &arrayname is a pointer to an array.  The array has the same
address as its first char, so this differs from a pointer to the first
char only in its type, not in its value.

>This is fundamental C programming. Have a look at Kernighan & Ritchie, or
>possibly the C FAQ.

You could have a look yourself, although I don't think K&R 2nd ed.
explains this very clearly, unless I have looked in the wrong places.

None of this is relevant to HPMAN's problem, but until he posts some
non-working code there's no way to tell what his problem is.

S.

- Raw text -


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