Conrad C-Control Pro Mega Series Manual page 101

Table of Contents

Advertisement

sizeof Operator
By the operator sizeof() the number of Bytes a variable takes up in memory can be determined.
Examples:
int s;
float f:
s=sizeof(f);
With arrays only the Byte length of the basic data type is returned. On order to calculate the
memory consumption of the array the value must be multiplied by the number of elements.
Array Variables
If behind the name, which in case of a variable definition is set in brackets, a figure value is written
then an array has been defined. An array will arrange the space for a defined variable manifold in
memory. With the following example definition
int x[10];
a tenfold memory space has been arranged for variable x. The first memory space can be addressed
by
], the second by
X[0
dimensions can also be chosen. The memory space of C-Control Pro is the only limit.
Multi dimensional arrays can also be declared by attaching further brackets during variable definition:
int x[3][4];
int y[2][2][2];
Arrays may in CompactC have up to
is 65535. The indices of arrays are in any case zero based, i .e. each index will start with a 0.
During program execution there will be no verification whether or not the defined index limits of an
array have been exceeded. If an index becomes too large during program execution the access to
alien variables will be tried which in turn may create a good chance for a program breakdown.
Strings
There is no explicit "String" data type. A string is based on a character array. The size of the array
must be chosen in such a way that all characters of the string fit into the character array.
Additionally some space is needed for a terminating character (decimal Zero) inorder to indicate the
end of the character string.
Example for a character string with a 20 character maximum:
char str1[21];
© 2008 Conrad Electronic
// the value of s is 4
, the third by
x[1]
// array with 3*4 entries
// array with 2*2*2 entries
16
, ... up to
. When defining of course other index
x[2]
x[9]
indices (dimensions). The maximum value for an index
Compiler
92

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

C-control pro mega32C-control pro mega128

Table of Contents