comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: String handling???
Date: Sun, 24 Jun 2001 23:56:52 GMT
Date: 2001-06-24T23:56:52+00:00	[thread overview]
Message-ID: <3B367E2B.D5F4A7F3@acm.org> (raw)
In-Reply-To: 3B362243.EA4AA94E@ida.his.se

Michael Andersson wrote:
> 
> I'm currently trying to write a text file parser from my collage project
> and I'm looking for some functions i Ada that works like the sprint
> function in C. Is there such a function?
> The thing is that I want to extract numbers from a string and I don't
> know how.

Assuming that "extract numbers" means convert from a text representation
in a String into the internal representation for a numeric type, you
have a number of options.

If your String contains a single value, possibly with leading or
trailing blanks, you can use the 'Value attribute. See your text or ARM
Annex K.

For more complex situations, there are procedures in Ada.Text_IO that
"read" from a string. See your text or ARM Annex A.10.

For parsing Strings, you might find the subprograms in Ada.Strings.Fixed
useful. See your text or ARM Annex A.4.3. The other child packages of
Ada.Strings might also be of interest.

However, none of these work exactly like sprint (if that really is a C
function for extracting numbers from a string). In general, Ada Strings
do not work like C strings. If that really is a requirement, you'll have
to write your own or import the C functions.

-- 
Jeff Carter
"Hello! Smelly English K...niggets."
Monty Python & the Holy Grail



      parent reply	other threads:[~2001-06-24 23:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-24 17:24 String handling??? Michael Andersson
2001-06-24 12:30 ` Dale Stanbrough
2001-06-24 12:30 ` David C. Hoos, Sr.
2001-06-24 12:49 ` Larry Kilgallen
2001-06-24 23:56 ` Jeffrey Carter [this message]
replies disabled

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