accès aux groupes de discussion, consultation et publication d'articles, recherche de "newsgroups"...
membres, identifiez-vous
é-mail Mot de passe
nouveau ? mot de passe oublié ?
Chargement... Chargement en cours...

Groupes français belges canadiens suisses internationaux Nétiquette
Échangez opinions et commentaires dans les forums de discussion.

Re: Lenght check failed

 [  Nouvelle Discussion Nouvelle discussion  |  Répondre au groupe Répondre au groupe  |  fr.comp.lang.ada ] 

Retour : Accueil du site fr comp lang ada   charte stats de ce groupe


  Sujet:   Re: Lenght check failed  
 De: animatri...@gmail.com
 Groupes: fr.comp.lang.ada
 Organisation: http://groups.google.com
 Date: 09. Feb 2008, 06:38:52
 References: 1 2 3
On 9 fév, 15:09, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> Tu peux déclarer une String sans spécifier sa taille à condition de
> l'initialiser immédiatement avec une valeur... par exemple, le
> résultat d'Ada.Strings.Unbounded.To_String.
>
> with Ada.Strings.Unbounded;
> procedure P is
>    Keyboard_Input : constant Ada.Strings.Unbounded.Unbounded_String :>      
Ada.Strings.Unbounded.Get_Line; -- longueur inconnue
>    S : constant String := Ada.Strings.Unbounded.To_String (Keyboard_Input);
> begin
>    ...
> end P;
>
> Maintenant si tu veux un tableau de chaînes de longueurs variables
> ("ragged array") il te faut un tableau de valeurs accès vers des
> String.  Par exemple:
>
> with Ada.Strings.Unbounded;
> with Ada.Unchecked_Deallocation;
> procedure Q is
>
>    type String_Access is access String;
>    type String_Array is array (Positive range <>) of String_Access;
>
>    procedure Free is
>      new Ada.Unchecked_Deallocation (Object => String, Name => String_Access);
>
>    Keyboard_Input : Ada.Strings.Unbounded.Unbounded_String;
>    Inputs : String_Array (1 .. 10);
> begin
>    Read_From_Keyboard: for J in Inputs'Range loop
>       Keyboard_Input := Ada.Strings.Unbounded.Get_Line; -- unknown length
>       Input (J) :>         new String'(Ada.Strings.Unbounded.To_String
(Keyboard_Input));
>       -- Input (J) is an access to a new string allocated on the heap with the
>       -- proper size
>    end loop Read_From_Keyboard;
>
>    -- process Inputs here
>
>    Deallocate_Each_String: for J in Inputs'Range loop
>       Free (Inputs (J));
>    end loop Deallocate_Each_String;
> end Q;
>
> Voir aussi:
>
>
http://en.wikibooks.org/wiki/Ada_Programming/Stringshttp://fr.wikibooks.org/wiki/Programmation_Ada/FAQ/(questions
2.17 et 2.6.)
>
> --
> Ludovic Brenta.

Merci pour les liens, je vais regarder ca.
Pour s, j'ai fait un 		s : string  :Ada.Strings.Unbounded.To_String(Str);


Merci bcp pour l'aide :)


DateSujet  Auteur
09.02.
* Re: Lenght check failed
Jeffrey R. Carter
09.02.
`* Re: Lenght check failed
animatrix30
09.02.
 `* Re: Lenght check failed
Ludovic Brenta
09.02.
  `* Re: Lenght check failed
animatrix30
09.02.
   `* Re: Lenght check failed
Ludovic Brenta
09.02.
    +-   Re: Lenght check failed
animatrix30
09.02.
    `* Re: Lenght check failed
Jeffrey R. Carter
10.02.
     `* Re: Lenght check failed
animatrix30
11.02.
      `* Re: Lenght check failed
Jeffrey R. Carter
11.02.
       +- Re: Lenght check failed
Pascal Obry
11.02.
       `* Re: Lenght check failed
Ludovic Brenta
11.02.
        `* Re: Lenght check failed
Jeffrey R. Carter
11.02.
         `- Re: Lenght check failed
animatrix30
Groups Explorer contact votre avis comment ça marche? rechercher un groupe suggérer un groupe abuse accueil du site   Imprimer cette page   Envoyer cette page à un(e) ami(e)