![background image](http://html.mh-extra.com/html/conrad/c-control-pro-mega-series/c-control-pro-mega-series_manual_2654183101.webp)
92
Compiler
© 2008 Conrad Electronic
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);
// the value of s is 4
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
X[
0
]
, the second by
x[
1
]
, the third by
x[
2
]
, … up to
x[
9
]
. When defining of course other index
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
];
// array with 3*4 entries
int y[
2
][
2
][
2
];
// array with 2*2*2 entries
Arrays may in CompactC have up to
16
indices (dimensions). The maximum value for an index
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
];
Summary of Contents for C-Control Pro Mega Series
Page 1: ... 2008 Conrad Electronic C Control Pro Mega Series ...
Page 9: ...VIII Inhalt 2008 Conrad Electronic ...
Page 10: ...Part 1 ...
Page 17: ...Part 2 ...
Page 23: ...Part 3 ...
Page 41: ...32 Hardware 2008 Conrad Electronic 3 3 5 3 Component Parts Plan ...
Page 57: ...48 Hardware 2008 Conrad Electronic 3 4 5 3 Component Parts Plan ...
Page 58: ...Part 4 ...
Page 91: ...82 IDE 2008 Conrad Electronic ...
Page 92: ...Part 5 ...
Page 135: ...126 Compiler 2008 Conrad Electronic 31 1F US 63 3F 95 5F _ 127 7F DEL ...
Page 136: ...Part 6 ...
Page 231: ...Part 7 ...
Page 240: ......