-
Notifications
You must be signed in to change notification settings - Fork 6
Variables and types
LucasMW edited this page Dec 8, 2017
·
2 revisions
Headache has three base types: byte, short and int
Variables are declared like this:
byte b;
short s;
int i;
Variables with the same type can also be declared like this:
byte x,y,z;
and it is equivalent to this
byte x;
byte y;
byte z;
Variables can only be declared at the beginning of a scope and before their use:
correct:
short f(short a) {
short x,y;
x = a;
y = a+3;
x = x+y;
return x+1;
}
wrong:
short f(int a) {
short x;
x = a;
short y;
y = a+3;
x = x+y;
return x+1;
}
variables are assigned with values of their type:
short x;
byte y;
x = 257;
y = 5+y;