comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Simple ADA/C Question
Date: 1997/02/27
Date: 1997-02-27T00:00:00+00:00	[thread overview]
Message-ID: <dewar.857057716@merv> (raw)
In-Reply-To: Pine.LNX.3.95.970225100418.10492A-100000@vf700f.msfc.nasa.gov


AE asks

<<I am very new to ADA ( 3-4 days experience ) and I have a question that
probably has a simple answer.  As part of my learning experience, I wrote
a simple piece of code that requests the user to enter an integer and then
the integer is displayed.  My ADA code calls a C function, which requests
and then returns the integer.  The primary ADA task consists of a loop so
the I can go get as many integers as I want as long as I input 'y' when
prompted ( the default is no ).  This works fine as long as I enter an
integer. If I enter a real, the program exits as if I had hit the default.
What am I forgetting to check to prevent a real, or any unexpected value,
from having this effect?  TIA.>>

your design is defective, to accept any character other than y as a
terminating character is a bad idea. In this case, the character read
is the period (if you input 21.35, the get of an integer will read only
the 21), and your program is working exactly as you intend (only though
I don't think you exactly intended this effect :-)





  parent reply	other threads:[~1997-02-27  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-25  0:00 Simple ADA/C Question root
1997-02-26  0:00 ` Bob Klungle
1997-02-26  0:00   ` root
1997-02-26  0:00     ` John McCabe
1997-02-26  0:00     ` Stephen Leake
1997-02-26  0:00       ` root
1997-02-26  0:00     ` Robert Dewar
1997-02-28  0:00       ` Keith Thompson
1997-03-02  0:00         ` Robert Dewar
1997-03-04  0:00           ` Keith Thompson
1997-03-04  0:00             ` Robert Dewar
1997-03-04  0:00               ` John McCabe
1997-03-04  0:00                 ` Robert Dewar
1997-03-06  0:00                   ` Keith Thompson
1997-03-06  0:00                     ` Robert Dewar
1997-03-06  0:00                     ` Larry Kilgallen
1997-03-09  0:00                       ` Robert Dewar
1997-03-04  0:00                 ` Anders Eliasson
1997-02-27  0:00 ` Robert Dewar [this message]
1997-02-27  0:00   ` root
1997-02-27  0:00   ` root
1997-03-03  0:00 ` Robert I. Eachus
1997-03-05  0:00   ` Robert Dewar
1997-03-05  0:00 ` Jon S Anthony
1997-03-06  0:00   ` Robert Dewar
1997-03-07  0:00 ` Jon S Anthony
1997-03-07  0:00   ` Robert Dewar
1997-03-08  0:00     ` Larry Kilgallen
1997-03-07  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox