comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: ATOI
Date: Sat, 12 Jul 2003 01:58:06 GMT
Date: 2003-07-12T01:58:06+00:00	[thread overview]
Message-ID: <3F0F6B08.9050200@attbi.com> (raw)
In-Reply-To: belta6$ghe$1@e3k.asi.ansaldo.it

Riccardo Fulcoli wrote:
> HI!
> I'm having problems reguarding the input/output from files in text mode.
> Exactly I would like to read a field as a string of 50 characters(and for
> that i'm using the redirection of the input) and after that to convert it in
> a number (an integer).
> i.e. I'm looking for a function like the C "atoi".
> Of course I already know that the content of the field is a numeric one but
> the unchecked conversions seems not to be good at the purpose.
> Is there someone that could help me???
> Thanks ;)
> 
> Riccardo

Why would you want to do an Unchecked_Conversion.  See Ada.Text_IO, or 
Ada.Integer_Text_IO.  But if you have already read in a string you can 
use the attribute function Integer'Value(Some_String).  Note that the 
function will ignore leading and trailing spaces, but otherwise can 
raise an exception which may not be what you want.  See RM 3.5(52)


-- 

                                                        Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




  reply	other threads:[~2003-07-12  1:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-11  8:39 ATOI Riccardo Fulcoli
2003-07-12  1:58 ` Robert I. Eachus [this message]
2003-07-14  1:49   ` ATOI Richard Riehle
2003-07-12  9:05 ` ATOI Preben Randhol
replies disabled

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