如何将一个int的各个单位存储在一个int数组中; C语言

我是一个从C开始的初学者,并且正在进行代码战方面的一些练习。练习需要我取一个十进制整数,将其转换为二进制并输出二进制数中的1s。下面是我不完整的代码。我将二进制文件存储在int b中,我想将其输出到数组中,这样我就可以运行循环来搜索1并输出总和。

提前致谢!

    #include <stddef.h>
#include <stdio.h>

//size_t countBits(unsigned value);
int countBits(int d);

int main() {
    int numD = 1234;
    int numB = countBits(numD);

    printf("The number %d converted to binary is %d \n", numD, numB);
}

int countBits(int d) {
    if(d < 2)
    {
        return d;
    }
    else {
        int b = countBits(d / 2) * 10 + d % 2; //convert decimal into binary
        int c;
        int bArray[c];

    }