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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bd4e40454c63169a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-12 04:11:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!washdc3-snh1.gtei.net!news.gtei.net!feeder.qis.net!btnet-peer!btnet!peer.news.eu-x.com!server2.netnews.ja.net!newshost.central.susx.ac.uk!news.bton.ac.uk!not-for-mail From: John English Newsgroups: comp.lang.ada Subject: Re: How to convert characters in a string into integers ? Date: Tue, 12 Feb 2002 12:03:21 +0000 Organization: University of Brighton Message-ID: <3C690489.2DC6927F@brighton.ac.uk> References: NNTP-Posting-Host: pcje.it.bton.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: saturn.bton.ac.uk 1013515329 27404 193.62.183.48 (12 Feb 2002 12:02:09 GMT) X-Complaints-To: news@bton.ac.uk NNTP-Posting-Date: 12 Feb 2002 12:02:09 GMT X-Mailer: Mozilla 4.7 [en-gb] (WinNT; U) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:19925 Date: 2002-02-12T12:02:09+00:00 List-Id: Jim wrote: > > is this possible, if so how ? > > say im reading a string (1 + 2 + 3) (yep carrying on with my calculator > program :-)) > > how to get 1 and the convert to integer, then get + and store as character, > get 2 and convert to integer etc ? One way is described in section 13.3 of the textbook you're using: you use Ada.Text_IO.Look_Ahead to see if the character you're about to read is a digit, and if it is use Ada.Integer_Text_IO.Get to read an integer. Another way is to convert this pseudocode to Ada: result = 0 while (next char is a digit) loop result = result * 10 + (value of digit char) end loop There are other ways than these, too... ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk -----------------------------------------------------------------