From: Cecilia Chew <cecilia@nowhere.com>
Subject: count_string program
Date: Thu, 26 Feb 2004 17:10:03 +0800
Date: 2004-02-26T17:10:03+08:00 [thread overview]
Message-ID: <403db7ee$1_1@news.tm.net.my> (raw)
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 <AT> g r e e n l i m e . c o m
next reply other threads:[~2004-02-26 9:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-26 9:10 Cecilia Chew [this message]
2004-02-26 10:17 ` count_string program Jacob Sparre Andersen
2004-02-27 3:13 ` Cecilia Chew
2004-02-27 11:00 ` Jacob Sparre Andersen
2004-02-26 15:43 ` Björn Persson
2004-02-27 3:19 ` Cecilia Chew
2004-02-27 6:49 ` tmoran
2004-02-27 18:29 ` Björn Persson
2004-02-27 13:28 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox