home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!ucsbuxa!6500msd
- From: 6500msd@ucsbuxa.ucsb.edu (Michael D'Errico)
- Newsgroups: comp.lang.c
- Subject: Re: Funny problem with a pause routine
- Message-ID: <6770@ucsbcsl.ucsb.edu>
- Date: 19 Nov 92 01:49:12 GMT
- References: <9232123.22703@mulga.cs.mu.OZ.AU>
- Sender: root@ucsbcsl.ucsb.edu
- Lines: 41
-
- In article <9232123.22703@mulga.cs.mu.OZ.AU> carl@montebello.ecom.unimelb.EDU.AU (Carl Brewer) writes:
-
- >ok, here's a routine I copied from a book, and can see no reason why
- >it won't work, but first, some background ..
-
- >[background deleted]
-
- >void pause()
- >{
- > char ans;
- > fflush(stdin);
- > fprintf(stdout, "Press <Return> to continue\n");
- > ans = getchar();
- > fflush(stdin);
-
- > return;
- >}
-
- >I've tried this with the getchar cast to void [ (void)getchar(); ],
- >and tried gets(), getc() etc, all to no avail.
-
- There are two things I don't like about this code (this is not a flame):
- 1) pause() is a UNIX system function
- defined in <unistd.h> so you should
- refrain from using that name.
-
- 2) getchar() returns an INT!!! This is so
- that EOF can be returned -- it doesn't
- fit in a char. This has repeatedly been
- discussed in this newsgroup since there
- is a tendancy to assume that a function
- called getchar() returns a char. It is
- far worse when a book claims this.
-
- I tried this code on my HP 9000 433s with cc and had no problems
- with it even with the 'char ans;' declaration, so I don't know what
- your problem could be...
-
- Michael D'Errico
- 6500msd@ucsbuxa.ucsb.edu
-
-