comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org>
Subject: Re: Is there an end of string like in C
Date: Fri, 30 Jun 2006 20:12:20 GMT
Date: 2006-06-30T20:12:20+00:00	[thread overview]
Message-ID: <EAfpg.12789$FQ1.9479@attbi_s71> (raw)
In-Reply-To: <1151691630.276880.203280@75g2000cwc.googlegroups.com>

Chris L wrote:
> In C, there is an end of string character ('\0'). Is there one in Ada?
> Can you give me code that checks for it in an array?

In Ada, a string type is a one-dimensional array type with components of 
a character type. You can define your own character types and your own 
string types. If you want to define your own end-of-string character and 
a library of operations that know about that character you certainly can.

The predefined type Character is a character type. The predefined type 
String is a string type. Its definition is

type String is array (Positive range <>) of Character;
pragma Pack (String);

The definitions of Character and String do not define an end-of-String 
Character or any operations that treat a Character as such.

The C approach is referred to in Ada as a bounded string; the logical 
value can vary in length from zero to some maximum number of characters. 
You can also consider an unbounded string, in which there is no upper 
limit to the length (except as imposed by available storage). You might 
want to look at Ada.Strings.Bounded and Ada.Strings.Unbounded for the 
Ada Way to do this sort of thing.

One advantage of the Ada Way is that all characters can be elements of a 
string.

This is all pretty basic and should be covered by any text or tutorial, 
which you should have worked through before asking questions such as 
this. You can find on-line texts and tutorials at www.adapower.com and 
www.adaworld.com.

-- 
Jeff Carter
"The time has come to act, and act fast. I'm leaving."
Blazing Saddles
36



      parent reply	other threads:[~2006-06-30 20:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1151691630.276880.203280@75g2000cwc.googlegroups.com>
2006-06-30 18:57 ` Is there an end of string like in C Pascal Obry
2006-06-30 19:20 ` Martin Dowie
2006-06-30 19:24 ` Gautier
2006-06-30 19:38 ` Björn Persson
2006-06-30 20:12 ` Jeffrey R. 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