以下のコードは、すべて 0 を表示します。理解できない。私のロジックに従って、適切に表示する必要があります。私は何が欠けていますか?
#include <stdio.h>
void displayInBıtFormat(int);
int i, value;
int main(void){
puts("Enter an integer");
scanf("%d",&value);
printf("\n%d's bit representation is: ",value);
displayInBıtFormat(value);
getch();
}
void displayInBıtFormat(int val){
int mask=1<<15;
for (i = 0; i < 16; i++)
{
if (val&mask==1)
{
printf("1");
}
else
{
printf("0");
}
if ((i+1)%8==0)
{
printf(" ");
}
val<<1;
}
}