delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/08/27/21:25:24

Date: Wed, 27 Aug 2003 21:25:15 -0400
Message-Id: <200308280125.h7S1PFP5020856@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <tHc3b.3480$cQ1.829301@kent.svc.tds.net> (melken@co.tds.net)
Subject: Re: Simple program. Strange results.
References: <HfZ2b.3213$cQ1 DOT 755278 AT kent DOT svc DOT tds DOT net> <hO%2b.16285$8i2 DOT 341 AT newsread2 DOT news DOT atl DOT earthlink DOT net> <tHc3b.3480$cQ1 DOT 829301 AT kent DOT svc DOT tds DOT net>
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Thanks for the corrections!  DJGPP's help gave no reason for the ampersand.

The very first line in the scanf documentation is:

"This function scans formatted text from `stdin' and stores it in the
variables pointed to by the arguments."

The "pointed to by the arguments" should have indicated that the
arguments are pointers, not values.

In addition, the examples show:

     scanf("%d %d %s", &x, &y, buf);

But, if you can suggest a more obvious wording, we'll listen.

>   From what I can grasp, the asterisk symbol means the same thing.
> Though I have yet to really grasp the proper place(s) and form(s)
> for its usage.

Nope, asterisk is the inverse of ampersand.  Ampersand takes the
address of something, converting values into pointers that point to
those values.  Asterisks dereference pointers, turning pointers into
the values they point to.

- Raw text -


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