Download PhrozenC user guide
Transcript
PhrozenC user guide
version 1.1
This above example initialize the i integer to 10, displays the ”Hello” string, decrements the i
value tills it reachs 0. The only difference with the previous example is that the evaluation is done
at the end of the code of block, instead of the beginning.
5.10
Arrays declaration and usage
Now let’s play with arrays :
# include " PRINT .C"
void main ( )
{
int i ;
int table [ 5 ] ;
table [ 0 ]
table [ 1 ]
table [ 2 ]
table [ 3 ]
table [ 4 ]
=
=
=
=
=
12;
−7565;
98;
−5;
267;
for ( i = 0 ; i < 5 ; i++ )
{
printdec ( i ) ;
}
}
This above example initialize the table array with 5 items, that are later initialized with values.
Please note that the first element in an array is designed by index 0, not 1. Finally, we use the
io printIntln function which allows to display an integer to screen with carriage return.
5.11
Switch/case statement
Instead of cumulating if statements, it’s possible to make custom code implementation depending
of a condition :
# include " PRINT .C"
void main ( )
{
int i ;
i = 4;
switch ( i )
{
case 4 :
printstrln ( " Value is 4" ) ;
break ;
case 2 :
24