I'm pretty sure you wrote hatvany() wrong. alap *= alap; doesn't really help much.
You want to do, for example:
res = 1;
alap = 2;
exp = 3;
res *= alap;
--exp;
res *= alap;
--exp;
res *= alap;
--exp;
By now res is 8, as you'd expect, and exp is 0. Perhaps a for loop that tests exp repeatedly is what you actually want.
Also you still need to initialize the answer to the whole calculation to 0 or 1 (depending on if you add or multiply, respectively).