From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,46ea53533b75e179,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-26 01:10:30 PST Date: Thu, 26 Feb 2004 17:10:03 +0800 From: Cecilia Chew User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: count_string program Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 219.95.194.109 X-Original-NNTP-Posting-Host: 219.95.194.109 Message-ID: <403db7ee$1_1@news.tm.net.my> X-Trace: news.tm.net.my 1077786606 219.95.194.109 (26 Feb 2004 17:10:06 +0800) Organization: TMnet Malaysia Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!wn52feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!news1.tm.net.my Xref: archiver1.google.com comp.lang.ada:5827 Date: 2004-02-26T17:10:03+08:00 List-Id: Hi all, I am doing a program that will count the input characters from user. There is a problem that I can't solve. Problem is : since I'm going to count the characters. So, I can't ask user how many characters they want to input. Compilation error come and mention that the string need to be constrainted. How am I going to constraint the string type since I don't know how many characters user going to input. Program is as follow: ======================================================================== with Ada.Text_Io, Ada.Integer_Text_Io; use Ada.Text_Io, Ada.Integer_Text_Io; procedure Count_String is type String is array (Positive range <>) of Character; Input : String; Count : Integer; begin Count := 0; Put ("Please enter a string :"); for I in Input'Range loop Get(Input(I)); Count := Count + 1; end loop; New_Line; Put ("There are" & Integer'Image(Count) & " characters"); end Count_String; ========================================================================= Problem occured at input : string; with compilation error: unconstrainted subtype not allowed. Please give any comments to this program. Thank you. -- Cecilia Chew c e c i l i a g r e e n l i m e . c o m