Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!csd4.milw.wisc.edu!uxc.cso.uiuc.edu!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Probably an easy or dumb question Keywords: scan Message-ID: <18998@mimsy.UUCP> Date: 11 Aug 89 09:25:19 GMT References: <1949@leah.Albany.Edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 31 In article <1949@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes: >Hello frenz, 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); Easy, yes; dumb, no: but the answer is no. >I guess the question is whether "scanf" uses the format string or >the number of arguments to determine how many thingies to convert. >So, what is it? It uses the format. In particular, the proposed ANSI C standard says that printf et al. can be given `extra' arguments, so these clearly must use the format rather than (or perhaps in addition to) the number and types of arguments; and given that, it is likely that the same will be true of scanf, whether or not it is required (I cannot recall offhand). In any case, even if it used the number of arguments, scanf("%d %d %d %d", d); would still pass only two arguments, one being a pointer to char that points to the first `%', and the other being a pointer to int that points to d[0]. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris