comp.lang.ada
 help / color / mirror / Atom feed
From: W1bBle <layabouts@the-giant-sofa.demon.co.uk>
Subject: Re: Weird get_line()
Date: 1999/03/28
Date: 1999-03-28T00:00:00+00:00	[thread overview]
Message-ID: <7dmci4$qgd$1@nnrp1.dejanews.com> (raw)
In-Reply-To: m3soaptpo9.fsf@mheaney.ni.net

In article <m3soaptpo9.fsf@mheaney.ni.net>,  Matthew Heaney
<matthew_heaney@acm.org> wrote: > W1bBle
<layabouts@the-giant-sofa.demon.co.uk> writes: >  > > I have an extremely
strange problem with get_line() > >  > > In the main part of the program, it
functions as normal. However, when it is > > used inside a loop (like you
would need to implement a basic text menu on > > your terminal) the program
appears to "skip" over the get_line() statement, > > removing the possibility
of user input, which kind of defeats the purpose of > > having a menu. get()
suffers no such problems. Any ideas? I'm using the > > gnat system. >  > Make
sure your line buffer is larger than (and not just equal) the > user's input.
 >  > Remember that the buffer holds both the actual data entered by the
user, > and an indication of whether the entire line has been consumed. >  >
See my response to the post "Sequential???" on 23 Jan 99 for an > explanation
of how Get_Line works. >  >  OK, thanks but I already knew that (like in C
where you need an array one bigger than the string you have to hold, to
handle the /0 chracter). Anyway...  I've discovered that after issuing a
get() and waiting for the user to input a number (from a menu choice) what
was happening was a /0 was left in the input stream. This made the get_line()
immediately following it think that you had pressed return. It just processed
whatever was left in stdin. So putting a get_line() command immediately after
the get() swallows the remaining /0 character and then another get_line()
reads the, now meaningful, input from stdin.  It appears that both the
version of gnat I'm using on Geek Gadgets (on an Amiga but also on BeOS
AFAIK) and the version running on an SGI server at my university share this
"feature." Is this behaviour part of the specification for get()? Surely it
would be designed to swallow that last /0 to prevent erroneous input? Has
anyone come across this before??? I only ask because it appears to me to be a
bit of an oversight on someone's part... ;)  C ya  W1bBle

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  reply	other threads:[~1999-03-28  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-28  0:00 Weird get_line() W1bBle
1999-03-28  0:00 ` Matthew Heaney
1999-03-28  0:00   ` W1bBle [this message]
1999-03-29  0:00     ` Matthew Heaney
     [not found] <yam7758.1500.1147822784@post.demon.co.uk>
1999-03-30  0:00 ` Matthew Heaney
replies disabled

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