Conrad C-Control Pro Mega Series Manual page 102

Table of Contents

Advertisement

93
C-Control Pro Mega Series
As an exception char arrays may have character strings assigned to. Here the character string is
placed between quotation marks.
str1="hallo
world!";
Strings cannot be assigned to multi dimensional Char arrays. There are however tricks for
advanced users:
char str_array[3][40];
char single_str[40];
single_str="A
String";
Str_StrCopy(str_array,single_str,40);
This will work because with a gap of 40 characters after the first string there will in str_array be room
for the second string.
Visibility of Variables
When variables are declared outside of functions then they will have global visibility. I. e. they can be
addressed from every function. Variable declarations within functions produce local variables. Local
variables can only be reached within the function. An example:
int a,b;
void func1(void)
{
int a,x,y;
// global b is accessable
// global a is not accessable since concealed by local a
// local x,y are accessable
// u is not accessable since local to function main
}
void main(void)
{
int u;
// globale a,b are accessable
// local u is accessable
// x,y not accessable since local to function func1
}
Global variables have a defined memory space which is available throughout the entire program run.
At program start the global variables will be initialized by zero.
Local variables will during calculation of a function be arranged on the stack. I. e. local variables
exist in memory only during the time period in which the function is executed.
If with local variables the same name is selected as with a global variable then the local variable will
// will copy single_str in the second string
© 2008 Conrad Electronic

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

C-control pro mega32C-control pro mega128

Table of Contents