comp.lang.ada
 help / color / mirror / Atom feed
* C getchar() functionality in Ada
@ 2009-02-16 20:36 Thomas Locke
  2009-02-16 21:43 ` Jeffrey R. Carter
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Thomas Locke @ 2009-02-16 20:36 UTC (permalink / raw)


Hey all,

I've started redoing all the K&R C examples in Ada, and I've already hit 
a wall that I'm not able to get around.

I have this C program:  http://pastebin.com/fbc6bec5

It's very simple, but still I fail to mimick it in Ada.

The C program happily accepts everything I throw at it, and it responds 
with the expected values, whereas my Ada version(s) either fail at 
linefeeds, throw End_Error exceptions at me, or spits out too many 
linefeeds!

My current Ada code looks like this: http://pastebin.com/f519f7e37

This version works with input from keyboard and when I pipe some data 
into it like this:  $ echo "FooBar" | ito

It craps out on files ($ cat SomeFile | ito), where it ignores linefeeds 
and throws End_Error exceptions at me when the last character in the 
file is a linefeed

I've tried with Get_Immediate, Look_Ahead, Get_Line and a mixture of 
Strings, Characters and Unbounded strings. I just can't make it work.

Any and all advice are more than welcome.

:o)
/Thomas



^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2009-03-03  8:57 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-16 20:36 C getchar() functionality in Ada Thomas Locke
2009-02-16 21:43 ` Jeffrey R. Carter
2009-02-17  7:23   ` Thomas Locke
2009-02-17  8:16     ` Niklas Holsti
2009-02-17 13:01       ` Georg Bauhaus
2009-02-17 22:03         ` Thomas Locke
2009-03-03  8:57         ` David Thompson
2009-02-17 20:48     ` Jeffrey R. Carter
2009-02-17 21:59       ` Thomas Locke
2009-02-16 23:46 ` Adam Beneschan
2009-02-17  7:19   ` Thomas Locke
2009-02-17  8:37     ` Jacob Sparre Andersen
2009-02-17 17:31       ` Keith Thompson
2009-02-17 14:57     ` Hibou57 (Yannick Duchêne)
2009-02-17 14:55   ` Hibou57 (Yannick Duchêne)
2009-02-17 10:37 ` m.collado
2009-02-17 22:07   ` Thomas Locke
2009-02-17 16:40 ` Jean-Pierre Rosen
2009-02-17 19:46   ` Thomas Locke
2009-02-17 20:24     ` Hyman Rosen
2009-02-17 23:44       ` Robert A Duff
2009-02-18  5:44         ` anon
2009-02-18  0:39       ` Adam Beneschan
2009-02-18  7:43     ` Jean-Pierre Rosen
2009-02-18 11:42       ` christoph.grein
2009-02-17 20:38   ` Jeffrey R. Carter
2009-02-18  7:46     ` Jean-Pierre Rosen
2009-02-18 10:41       ` christoph.grein

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