A
A
adrash kh2019-02-05 18:33:17
C++ / C#
adrash kh, 2019-02-05 18:33:17

How to convert from int to char in SI?

Good afternoon. I want to display a number in putchar, but putchar only outputs string variables. How can I stringify my numeric variable?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Dubrovin, 2019-02-05
@z3apa3a

To directly answer the question, then assuming that you only confused characters and strings, like this

int i=5;

putchar ('0'+i);

but I suspect that this is not what is really needed at all, tk. You probably confused more than just characters and lines.

V
Vladimir T, 2019-02-05
@32bit_me

putchar writes only 1 character to the output stream.
Probably what you really need is this:
printf("%d\n", i);

I
Incerti, 2019-02-06
@Incerti

int i = 97;
char a = i;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question