Right now I am trying to convert an int to a char in C programming. After doing research, I found that I should be able to do it like this:
int value = 10;
c
A portable way of doing this would be to define a
const char* foo = "0123456789ABC...";
where ...
are the rest of the characters that you want to consider.
Then and foo[value]
will evaluate to a particular char
. For example foo[0]
will be '0'
, and foo[10]
will be 'A'
.
If you assume a particular encoding (such as the common but by no means ubiquitous ASCII) then your code is not strictly portable.