Create char array of integer using digits as size

后端 未结 5 420
情歌与酒
情歌与酒 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:34

    You'll need to use malloc to allocate a dynamic amount of memory.

    Initializing the way you did is allowed only if the size is known at compile time.

提交回复
热议问题