vendredi 27 février 2015

Calculating powers of 2, prints out 0 every time



Here's my code:



int foo() {
int a = 1;
while(1) {
a *= 2;
printf("a = %d\n", a);
}
return a;
}


int main(void) {
foo();
return 0;
}


It just keeps printing out "a = 0". I'm confused! Am I missing something really simple?




Aucun commentaire:

Enregistrer un commentaire