Печать 0
в 64-битной среде с %lu
дает 140733193388032
вывод.
Я печатаю 8 раз 0
в 64-битной среде, а после 6-го числа значение печатается как 0
, а последние 2 печатаются 140733193388032
.
#include <stdio.h>
struct size {
unsigned long length;
unsigned long breadth;
};
struct pad {
unsigned long len;
unsigned long bre;
unsigned char hei;
unsigned char pad[7];
};
int main() {
unsigned long a;
unsigned long b = 0;
struct size sz;
struct pad sz1;
printf("%lu is a, %lu is b , %lu is length, %lu is breadth, %lu is len, "
"%lu is bre, %lu is hei, %lu is zero\n",
a, b, sz.length, sz.breadth, sz1.len, sz1.bre, sz1.hei, 0);
printf("%lu is a, %lu is b , %lu is length, %lu is breadth, %lu is len, "
"%lu is bre, %lu is hei, %lu is zero",
0, 0, 0, 0, 0, 0, 0, 0);
}
Выход:
140737488347824 is a, 0 is b , 0 is length, 4195408 is breadth, 140737346312864 is len, 4195893 is bre, 140733193388064 is hei, 140733193388032 is zero
0 is a, 0 is b , 0 is length, 0 is breadth, 0 is len, 0 is bre, 140733193388032 is hei, 140733193388032 is zero
С Инициализирующей структурой и локальным:
#include <stdio.h>
struct size {
unsigned long length;
unsigned long breadth;
};
struct pad {
unsigned long len;
unsigned long bre;
unsigned char hei;
unsigned char pad[7];
};
int main() {
unsigned long a = 0;
unsigned long b = 0;
struct size sz = { 0 };
struct pad sz1 = { 0 };
printf("%lu is a, %lu is b , %lu is length, %lu is breadth, %lu is len, "
"%lu is bre, %lu is hei, %lu is zero\n",
a, b, sz.length, sz.breadth, sz1.len, sz1.bre, sz1.hei, 0);
printf("%lu is a, %lu is b , %lu is length, %lu is breadth, %lu is len, "
"%lu is bre, %lu is hei, %lu is zero",
0, 0, 0, 0, 0, 0, 0, 0);
}
Выход:
0 is a, 0 is b , 0 is length, 0 is breadth, 0 is len, 0 is bre, 140733193388032 is hei, 140733193388032 is zero
0 is a, 0 is b , 0 is length, 0 is breadth, 0 is len, 0 is bre, 140733193388032 is hei, 140733193388032 is zero