Re: Is there an end of string like in C



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
.



Relevant Pages

  • Help in Spanish translation of the description of UDFs
    ... functions of minimum / maximum values among elements of an array column. ... GETALLWORDS- Inserts the words from a string into a global dimensioned ... WORDTRAN- Searches a character string for occurrences of a first word, ... ARRAYSUM- Returns the sum of all or a specified range of numeric (and/or ...
    (microsoft.public.fox.helpwanted)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • Re: Check for Common character sequence ( I will pay)?
    ... Do I need to return an array? ... You need to identify character sequences of 3 or more characters that appear ... in more than one string. ... and test each 3-character sequence that results. ...
    (microsoft.public.dotnet.framework)
  • Re: Desirable Usage of Fortran Modules
    ... suppose we want to cast a character array as ... A function that returns a string ... array of double precision numbers: ...
    (comp.lang.fortran)
  • Re: Check for Common character sequence ( I will pay)?
    ... Yes you are returning an array of FoundString objects. ... in more than one string. ... This means that you have to identify sequences 1 character at a time, ... Again, obviously, if the 3-character sequence doesn't match, neither will ...
    (microsoft.public.dotnet.framework)