delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/27/01:55:58

Date: Tue, 27 Mar 2001 08:52:04 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Jack Klein <jackklein AT spamcop DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: is this a bug?
In-Reply-To: <amb0ct41pn1s6rndo0bg9k5e2uif2e89jv@4ax.com>
Message-ID: <Pine.SUN.3.91.1010327085011.19916B-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 27 Mar 2001, Jack Klein wrote:

> >  scanf("%s", &string);
> 
> The line above is incorrect, the name of a character array like string
> is always converted to a pointer to its first element when passed to a
> function.  Just "string" is the address of string[0].  &string is a
> pointer to an array of characters, not a pointer to char.  This just
> happens to work on most compilers "by accident".

It works, and not by accident.  But you are right: it's bad C.

- Raw text -


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