comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: After typing input of Integer it SKIPS getting the inputs of String.
Date: Sat, 11 Jul 2015 18:36:00 +0300
Date: 2015-07-11T18:36:00+03:00	[thread overview]
Message-ID: <d0crf0Fcfr0U1@mid.individual.net> (raw)
In-Reply-To: <4ab70bc8-b25f-4dc4-88d9-d7021c2bed30@googlegroups.com>

Flip answer to "question" in Subject: Yes, it does. So what?

(That is, you could have been clearer about what you see as the problem, 
and what your question is.)

Better answer below:

On 15-07-11 18:14 , Trish Cayetano wrote:
> Code:
> with ada.Text_IO; use ada.Text_IO;
> with ada.Integer_Text_IO; use ada.Integer_Text_IO;
> procedure Main is
>
>
>     inputText: String (1..10);
>     inputNmbr : Integer;
>     StringNatural: Integer;
> begin
>
>     Put_Line("Enter Integer");
>     Get(inputNmbr,1);

The Get operation for integers leaves the "input point" after the last 
of the characters that form the integer. In this case, that point is 
before the "end of line" marker for that input line. If you then 
immediately call Get_Line, it will read characters up to the end-of-line 
marker, so it will return an empty string.

In your program, you evidently expect the Get_Line to start reading from 
the _next_ line after the line that contains the integer. So insert a 
Skip_Line between the Get(inputNmbr) and the Get_Line; that will pass 
the input point over the end-of-line so that the Get_Line starts reading 
from the start of the next line.

>     Put_Line("Enter String");
>     Get_Line(inputText,StringNatural);

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .

  reply	other threads:[~2015-07-11 15:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-11 15:14 After typing input of Integer it SKIPS getting the inputs of String Trish Cayetano
2015-07-11 15:36 ` Niklas Holsti [this message]
2015-07-11 18:05 ` Jeffrey R. Carter
replies disabled

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