How to convert integer to char without C library?

前端 未结 3 733
盖世英雄少女心
盖世英雄少女心 2021-01-28 09:31

In a c programming exercise I am asked to convert an int to char without using the C library.

Any idea how to go about it?

edit: what I mean by int is the built

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-28 09:38

    For completeness, if the task is to convert int to string as anthares suspects, you can use Mark's second answer to convert each digit of the integer. To get each digit, you have to look into the division and modulo operators.

提交回复
热议问题