Re: help with string splitting



isaac2004 wrote:

First_Half_Index : Positive := 1;
Second_Half_Index : Positive := 2;


for Code_Index in Codetext'Length loop
> if Code_Index <= Codetext'Length / 2 then
> Plaintext(First_Half_index) := Codetext(Code_Index);
First_Half_Index := First_Half_Index + 2;
else
Plaintext(Second_Half_Index) := Codetext(Code_Index);
Second_Half_Index := Second_Half_Index + 2;
end if;
end loop;

this code confuses me
what is Code_Index and Codetext'Length

Code_Index is a variable declared as part of for loop. C99 can do that as
well - finally ;-) . See:

http://en.wikibooks.org/wiki/Ada_Programming/Control#for_loop

Codetext'Length is the length of the array - mind you I would have used
Codetext'Range - which is range of valid indices for Codetext. See:

http://en.wikibooks.org/wiki/Ada_Programming/Attributes/'Length
http://en.wikibooks.org/wiki/Ada_Programming/Attributes/'Range

Martin
--
mailto://krischik@xxxxxxxxxxxxxxxxxxxxx
Ada programming at: http://ada.krischik.com
.



Relevant Pages

  • Re: Newbie pointers and reversing question
    ... If you are using C99 you can use ... char tmp; ... int main ... If i remove the while loop it prints the correct value 7!How does the while loop affect the value of printf?Seems strange to me! ...
    (comp.lang.c)
  • Re: "Sorting" assignment
    ... Yes, this is also legal C (traditional, C90, and C99) as written. ... the first substatement is executed if the expression ... In the else form, the second substatement is ... When you jump into a loop, on the other hand, the loop test is executed ...
    (comp.programming)
  • Re: Error: for loop initial declaration used outside c99 mode
    ... 'for' loop initial declaration used outside c99 mode ... It's an error message about some code that you failed to show us. ... which declares the loop variable as part of the for loop itself. ... You can either use C99 mode (but beware: ...
    (comp.lang.c)
  • Re: switch/continue
    ... Christopher Benson-Manica writes: ... > The indicated continue statement will apply to the for loop, ... As C99 says, "A continue statement causes a jump to the ... that a switch statement is not an iteration statement. ...
    (comp.lang.c)
  • Re: help with string splitting
    ... this code confuses me ... Following the encrypted example, Mother would encrypt to ... that is my mistake it is really Mteohr ... the reason for doing that is to loop through the string and reading all ...
    (comp.lang.ada)