将一整数逆序后放入一数组中,要求递归实现

#include <stdio.h>

void convert(int *result, int num) {
    if (num < 10) {
        *result = num;
    } else {
        *result = num % 10;
        convert(result + 1, num / 10);
    }
}

int main(int argc, char *argv[]) {

    int result[3] = {};
    int num = 5129;

    convert(result, num);

    for (int i = 0; i <= sizeof(result) / sizeof(result[0]); i++) {
        printf("%d", result[i]);
    }
    printf("\n");
}