Create char array of integer using digits as size

后端 未结 5 408
情歌与酒
情歌与酒 2020-12-19 05:30

I am trying to create a char array in C, to fill it with the digits of an int, but the int can be of any number of digits.

I\'m using a created function called

5条回答
  •  粉色の甜心
    2020-12-19 06:18

    try something like:

     char* buffer =(char *)malloc(getDigits(number)*sizeof(char));
    

    malloc and calloc are used to dinamic allocation.

提交回复
热议问题