Muhamed Cicak Muhamed Cicak - 15 days ago 4x
C Question

Cant i store 4294967295 in unsigned int ? Int is 4 bytes on my machine

Why am i getting 0 ?? And compiler warning:

format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’

Here is the code :

#include <stdio.h>

//function declerations...
int power(int base, int on);

int main(void) {
printf("%d",power(2, sizeof(int)*8)-1);
return 0;

int power(int base, int on) {
int pf = 1;
for (int i = 0; i < on; i++) {
pf *= base;
return pf;

If int is 4 bytes on my system,i guess i should be able to store 4294967295 in unsigned int.


If your int or unsigned int is 32-bits, neither can store the value 4294967296 since this is 2**32 which would require a 64-bit type.

Even uint32_t can only store the max value 2**32 - 1 so your value is just 1 out of range.

But int32_t can store the max positive value 2**31 - 1 so the signed type is even further off.