Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!unido!ztivax!tumuc!lan!foessmei
From: foessmei@lan.informatik.tu-muenchen.dbp.de (Reinhard Foessmeier)
Newsgroups: comp.lang.c
Subject: Re: Probably an easy or dumb question
Summary: "scanf" needs an address for each datum
Keywords: scan
Message-ID: <727@tuminfo1.lan.informatik.tu-muenchen.dbp.de>
Date: 11 Aug 89 07:28:59 GMT
References: <1949@leah.Albany.Edu>
Sender: news@lan.informatik.tu-muenchen.dbp.de
Reply-To: foessmei@lan.informatik.tu-muenchen.dbp.de (Reinhard Foessmeier)
Organization: Inst. fuer Informatik, TU Muenchen, FR Germanujo
Lines: 34

In article <1949@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes:
>...is it workable to pass only the base address of an array
>to "?scanf" and have it convert into successive memory locations?
>
>int    d[4];
>
>scanf("%d %d %d %d", d);
>
>I guess the question is whether "scanf" uses the format string or
>the number of arguments to determine how many thingies to convert.

"scanf" uzas la formatan vicon;         "scanf" uses the format string; it
^gi ne scias la nombron de argumentoj;  doesn't know about the # of args; but
tamen via propono ne funkcias.          what you propose doesn't work all the
La kawzo estas, ke "scanf" volas        same. The reason is that "scanf" wants
propran adreson por ^ciu legata         an address of its own for every datum
dateno.  ^Car la adreso de unu          read. Since the address of a single
elemento de estas distingebla de        element is not distinguishable from the
la adreso de vektoro, "scanf" ne        address of an array, "scanf" would be
scius kion fari el                      at a loss with something like

        scanf(" %d %d %d", d1, d2);

d1 kaj d2 povus esti deklaritaj kiel    d1 and d2 might be declared as

        int d1[2], d2[1];
aw                                      or
        int d1[1], d2[2];

"scanf" absolute ne scias, kiu el       "scanf" has no way of telling which of
la du deklaracio antawiris.             these declarations was used.
Reinhard F\"ossmeier, Technische Univ. M\"unchen |  Vivu
foessmeier@infovax.informatik.tu-muenchen.dbp.de |    la gefiloj
   [ { relay.cs.net | unido.uucp } ]             |       de niaj gepatroj!