delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/03/00:46:10

From: damnulp AT netins DOT net (DamnULP)
Newsgroups: comp.os.msdos.djgpp
Subject: Several questions on data input and checking
Date: Sat, 03 Jan 1998 05:15:27 GMT
Organization: Just Me
Lines: 30
Message-ID: <34ada35b.324349151@news.netins.net>
NNTP-Posting-Host: ins8.netins.net
Mime-Version: 1.0
Cache-Post-Path: ins8.netins.net!unknown AT tiff-03-26 DOT dialup DOT netins DOT net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

The usual "I'm new to C++" statements here....


I'm working on a program that requires a bit of input from the user:

while (ge<0 | ge>1000)
{
gotoxy(10,4);  cout<<"What is the germanium concentration (in g/l)?\n";
gotoxy(70,4);  cin>>ge;
}

This works fine until someone enterssomething like a "w".  Then it goes
into an loop that can only be exited by the ctrl-brk key.  Is there a way
to check for this and stop the loop from starting?

Also, after several more of these loops asking for other data, I ask for a
line of comments, viz:

gotoxy(10,15); cout <<"Please enter any other relevent comments....\n";
gotoxy(15,16); cin.getline(comm,65);

this gets skipped each time and the comments array is blank.  The same type
of statements work fine earlier in the program.  Any ideas why it works
before the cin statements but not after?

tia for any help.

---

DamnULP

- Raw text -


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