CS计算机代考程序代写 /* To build gcc int_align.c; ./a.out */

/* To build gcc int_align.c; ./a.out */

#include
#include #include

#define VAR_TO_STR_BIN(x) \
obj_to_bin((char[sizeof(x) *CHAR_BIT + 1]){“”}, &(x), sizeof(x))

char *obj_to_bin(char *dest, void *object, size_t osize) {
const unsigned char *p = (const unsigned char *)object;
p += osize;
char *s = dest;
while (osize– > 0) {
p–;
unsigned i = CHAR_BIT;
while (i– > 0) {
*s++ = ((*p >> i) & 1) + ‘0’;
}
}
*s = ‘\0’;
return dest;
}

void main() {
int i_int;
uintptr_t integer_value_pointer;
integer_value_pointer = (uintptr_t)&i_int;
long long int i_long_long;
printf(“Sizeof data : %ld, Address, of data %p, Address in Binary (look at ”
“lower bits), %s “,
sizeof(i_int), &i_int, VAR_TO_STR_BIN(integer_value_pointer));
integer_value_pointer = (uintptr_t)&i_long_long;
printf(
“\n Sizeof data : %ld, Address, of data %p, Address in Binary (look at ”
“lower bits), %s “,
sizeof(i_long_long), &i_long_long, VAR_TO_STR_BIN(integer_value_pointer));
}