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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5ed7b28464be2e1a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!feed.news.tiscali.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Another problems of newbie Date: Fri, 31 Dec 2004 08:04:38 +0100 Organization: None Message-ID: <1640924.dHkY6WWRQp@linux1.krischik.com> References: Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1104485514 03 32356 5E9sruEJ+rBMmB- 041231 09:31:54 X-Complaints-To: usenet-abuse@t-online.de X-ID: Jrgc00ZO8eGicTRn76NPvHS0LI+Gj8rLea9j1Rwe2s5R1f9n5paGEP User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:7337 Date: 2004-12-31T08:04:38+01:00 List-Id: maxsio ;D wrote: Just a few hints. After all, you need to learn something. > I need to write some program and I have problems with it. This program > should read text file, write words to array, sort them and than write to > another text file. In one book I found way how to read only singel char so > I thought it would be easy to link singel char and rest part of final > word, but I was wrong. I've written this subprogram (this program is > reading from keyboard, but with files is similar so...) : > * > procedure chars is > word : string(1..31); I take it you are a C/C++ programmer - otherwise you would not create a string wich is one char larger then actualy needed. > char : character; > > begin > for i in 1..30 loop for i in word'range loop > Get(char); > word:=word&(string(char)); Ada "string" is "char []" and "Ada.Strings.Unbounded" is "std::string". And you would not use operator + () on a char [], would you? So its: word (i) := char; > end loop; > Put(word); > delay 10.0; > end chars; > * > but after first letter program generate constraint error. And second > problem which I have is sorting array with words. To sort array I've > choosen QuickSort, but I don't know totally how to use it in Ada. I was > searching in Google, but I found only QuickSort with pointers. > Unfortunately I don't understand how to use them good ind this algorithm. > If anybody could explain usage of pointers in this algorithm or write > QuickSort without pointers I'd be grateful. > Sorry for my poor English and thanks in advance. Greetings > > maxsio > -- > maxsio@wp.pl > GG: 1447475 > IRC: irc.efnet.pl #osiolek Free yourself from C/C++ thinking! C/C++ are only mid-level languages and now you work with a true high level language. Things are diffreren here. i.E. if you need 30 characters you say 30 and 31 - no need for '\0' here. Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com