C语言如何将相应的整数转换为二进制

请问这个要怎么解决?应该是 输入整数,返回相应的16 个字符。在“PUT YOUR CODE HERE”写内容,前面内容不要改动,(好像是在于char和int的转化,要按照原来的0/1把int16_t对应的位设置成0/1,在计算机中就是那一串二进制数了,print出来直接是所表示的十进制数。但这个是二进制转相应整数的思路,和这个不一样),蟹蟹大lao。题目如下

img

img

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#define N_BITS 16
char *sixteen_out(int16_t value);
int main(int argc, char *argv[]) {
    for (int arg = 1; arg < argc; arg++) {
        long l = strtol(argv[arg], NULL, 0);
        assert(l >= INT16_MIN && l <= INT16_MAX);
        int16_t value = l;
        char *bits = sixteen_out(value);
        printf("%s\n", bits);
        free(bits);
    }
    return 0;
}
// given a signed 16 bit integer
// return a null-terminated string of 16 binary digits ('1' and '0')
// storage for string is allocated using malloc
char *sixteen_out(int16_t value) {
    // PUT YOUR CODE HERE
}
 

char *sixteen_out(short int  value) 
{
    char *p = new char[17];
    memset(p,'0',16);
    p[16] = 0;
    unsigned short int v = value;
    int i=15;
    do
    {
        p[i--] = v%2+'0';
        v/= 2;          
    }while(v>0);
    return p;
}