Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Converting ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 5 Topic 5624 of 5800
Post > Topic >>

Re: Converting Type Characters to type string

by "jimmaureenrogers@[EMAIL PROTECTED] " <jimmaureenrogers@[EMAIL PROTECTED] Mar 30, 2008 at 02:28 PM

On Mar 30, 3:08 pm, jedivaughn <jedivaugh...@[EMAIL PROTECTED]
> wrote:
> number 1 thank you so much for the fast response. But when I try your
> suggestion and use say "1234" for the input I get the number 1, a few
> spaces, and then some smiley faces. not exactly what I was hoping
> for :) .  Here's my code if that's any help.
>
> with ada.text_IO, ada.integer_text_IO;
>
> procedure integers is
>
> index : natural :=0;
> char : character;
> str : string (1..10);
>
> begin
>
>     ada.text_IO.put("Please enter a few Integers ");
>     ada.text_IO.get(char);
>
>     Index := Index + 1;
>     Str(Index) := Char;
>     ada.text_IO.put(str);
>
> end integers;

Your example contains no loop, so it only gets a single character.

Ada strings are not null terminated like C strings. They are fixed
length data items.
A proper output of the character you collected is

   Ada.Text_IO.Put(Str(1..Index));

Jim Rogers
 




 5 Posts in Topic:
Converting Type Characters to type string
jedivaughn <jedivaughn  2008-03-30 13:04:56 
Re: Converting Type Characters to type string
Pascal Obry <pascal@[E  2008-03-30 22:19:43 
Re: Converting Type Characters to type string
jedivaughn <jedivaughn  2008-03-30 14:08:53 
Re: Converting Type Characters to type string
"jimmaureenrogers@[E  2008-03-30 14:28:11 
Re: Converting Type Characters to type string
Ludovic Brenta <ludovi  2008-03-30 23:38:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 19:17:42 CDT 2008.