Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!decvax!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.unix.wizards Subject: Re: Unix problem or C problem? Message-ID: <396@lakart.UUCP> Date: 19 Jan 89 16:10:05 GMT References: <245@ibd.BRL.MIL> Organization: Lakart Corporation, Newton, MA Lines: 29 From article <245@ibd.BRL.MIL>, by heilpern@ibd.BRL.MIL (Mark A. Heilpern ): > When running a program with the following code: > > while (fscanf(input,"%d",stars)!=EOF) > { > fprintf(stderr,"OK to this point.\n"); > fprintf(output,"%4d |",lines++); > stars /= 50; > for (count = 0; count <= stars; count++) > fprintf(output,"*"); > fprintf(output,"\n"); > } > > I get the following error message, NOT put out from my program: Try fscanf(input, "%d", &stars) ^ ^ TO ASSIGN INTO AN int, scanf() NEEDS THE ADDRESS As an aside, I generally avoid testing scanf() values against EOF. scanf() returns the number of successful assignments (1 in this case), so you may be a lot safer saying: while (fscanf(input, "%d", &stars) == 1) -- dg@lakart.UUCP - David Goodenough +---+ IHS | +-+-+ ....... !harvard!xait!lakart!dg +-+-+ | AKA: dg%lakart.uucp@xait.xerox.com +---+