// 使用int正常运行, 改成int8_t num始终读成0
#include <stdio.h>
#include <stdint.h>
void convert(int8_t, int8_t);
int main(int argc, char const *argv[]) {
int8_t num;
int8_t b;
printf("enter a number:\n");
while (1 == scanf("%d", &num)) {
scanf("%d", &b);
printf("%d %d\n", num, b);
printf("Code: ");
convert(num, b);
putchar('\n');
printf("enter a integer (q to quit):\n");
}
printf("done.\n");
getchar();
return 0;
}
void convert(int8_t n, int8_t base) {
if (n >= base)
convert(n / base, base);
printf("%d", n % base);
return;
}