Mam do napisania makro, które będzie odwracać bity i je wyświetlać.
Napisałem tyle i niestety wyświetla same zera... w czym jest problem?
I wychodzą mi również takie błędy :/
#define REVERSE_BITS(pointer_to_variable){\
int zm=sizeof(pointer_to_variable);\
for(int i=0;i<=zm*8-1;++i)\
{\
if((pointer_to_variable&((unsigned long long int)1<<i))==0)\
{\
printf("0");\
}else\
{\
printf("1");\
}\
}\
}
wywołanie:
unsigned int liczba;
unsigned int* wow = &liczba;
if (scanf("%u", wow) != 1)
{
printf("Incorrect input"); return 1;
}
REVERSE_BITS(*wow);
BŁĘDY:
^~~~~~~~~~~~
unit_test_v2.c:2948:17: note: in expansion of macro ‘REVERSE_BITS’
REVERSE_BITS(&v);
^~~~~~~~~~~~
functions.h:10:33: error: invalid operands to binary & (have ‘unsigned char *’ and ‘int’)
if((pointer_to_variable&((int)1<<i))==0)\
^~~~~~~~~~~~
unit_test_v2.c:2953:17: note: in expansion of macro ‘REVERSE_BITS’
REVERSE_BITS(&v);
^~~~~~~~~~~~
unit_test_v2.c: In function ‘UTEST78’:
functions.h:10:33: error: invalid operands to binary & (have ‘unsigned char *’ and ‘int’)
if((pointer_to_variable&((int)1<<i))==0)\
^~~~~~~~~~~~
unit_test_v2.c:2989:17: note: in expansion of macro ‘REVERSE_BITS’
REVERSE_BITS(&v);
^~~~~~~~~~~~