From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fa4a527ee1c9d1e6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.inode.at!news.hispeed.ch!linux2.krischik.com!news From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Using fwrite in Ada Date: Wed, 10 Aug 2005 20:05:55 +0200 Organization: Cablecom Newsserver Message-ID: <2629229.pEnVhKcNl9@linux1.krischik.com> References: NNTP-Posting-Host: 84-73-3-177.dclient.hispeed.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.hispeed.ch 1123697197 32327 84.73.3.177 (10 Aug 2005 18:06:37 GMT) X-Complaints-To: news@hispeed.ch NNTP-Posting-Date: Wed, 10 Aug 2005 18:06:37 +0000 (UTC) User-Agent: KNode/0.9.2 Xref: g2news1.google.com comp.lang.ada:4071 Date: 2005-08-10T20:05:55+02:00 List-Id: Makhno wrote: > Hello, > I want to read and write binary data from stdin/stdout, unfortunately > Ada's usual IO routines appear to be text only and (on Win32) convert code > 10 to codes 10 & 13. Not at all true: http://en.wikibooks.org/wiki/Programming:Ada:InputOutput Sadly the articles which describe how to attach any stream type to stdin/stdout has not been written yet :-( . > To get round this I'm trying to use Interfaces.C_Streams, but I don't know > enough Ada to get them working. > How to I get a String into the fwrite function? > I tried > > procedure MainCode is > > cptr : chars_ptr; > Buffer : String (1..100); Are you sure you use the right String type? http://en.wikibooks.org/wiki/Programming:Ada:Strings > vptr : voids; > > begin > > -- fill Buffer with binary data here > > cptr:=New_String(Buffer); > vptr:=voids(cptr); > > fwrite(vptr,100,1,stdout); > end; > > But this won't compile, the compiler says that it cannot convert the > chars_ptr to voids. Coming from a C background, I don't understand why > something cannot be cast to void. Read: http://en.wikibooks.org/wiki/Programming:Ada:Subtypes#Converting_data and http://en.wikibooks.org/wiki/Programming:Ada:Types:access > Does anybody have any idea as to how I get binary data onto stdout? If it is truly binary data of a fixed length of 100 bytes I would suggest Direct I/O: http://en.wikibooks.org/wiki/Programming:Ada:InputOutput#Direct_I.2FO But you should really read the suggested web pages. Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com