comp.lang.ada
 help / color / mirror / Atom feed
From: "Mika Fischer" <mika_fischer@hotmail.com>
Subject: End_Of_File does not work as expected...
Date: Sat, 25 Nov 2000 00:42:19 +0100
Date: 2000-11-25T00:42:19+01:00	[thread overview]
Message-ID: <rcumv8.b93.ln@127.0.0.1> (raw)

Hi!

I have a problem with a program I had to write for university.

The program is supposed to read its standard input and write it onto its
standard output.

Why does the following code not work as expected?

procedure Echo is

c: Character;

begin
	while not End_Of_File loop
		Get(c);
		Put(c);
	end loop;
end Echo;

When I compile it and invoke it like in "cat file | ./echo" it throws the
exception END_ERROR which indicates that I tried to read from a file
beyond the end of file.
So why is End_Of_File false when it should be true?

Also if I invoke the program as "./echo" and type for example "ddd" and
press the enter key, the following appears on my screen:

--<snip>--
ddd
ddd
--<snip>--

When I press Enter once more its this:

--<snip>--
ddd
ddd


--<snip>--

I also don't understand why it behaves as it does.

I'm using GNAT 3.13p-2 on Debian GNU/Linux (woody) and Linux
2.4.0-test10.

As you have certainly noticed I don't really have a clue about Ada. So my
apollogies if this question ist just too stupid :-) (And sorry for my
English...)

Thanks for any answers!

Mika



             reply	other threads:[~2000-11-24 23:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-24 23:42 Mika Fischer [this message]
2000-11-25  5:14 ` End_Of_File does not work as expected Jeff Carter
2000-11-25  0:00   ` Mika Fischer
2000-11-25  0:00     ` Jeff Carter
2000-11-26  0:00 ` Mats Weber
2000-11-26  0:00   ` Jeff Carter
2000-11-26  0:00     ` Mats Weber
replies disabled

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