I want to convert an integer to a character. I am new to C++ and used static type conversion but that is giving me weird characters.
Actual Case: I do not want the integer to be converted into a string because ultimately I have a vector of vector of characters vector<vector<char>> vec
and I want to replace vec[i][j]
with integer i
. I tried doing vec[i][j] = (character conversion of i as below)
:
int i = 1; //I want a character '1'
cout<<char(i); //It outputs ╔
cout<<(char)(i); //It outputs ╔
cout<<static_cast<char>(i); //It outputs ╔
I am curious to what might be going wrong in above type conversion? Also How can I change a character via its [i][j]
index in a vector<vector<char>>
.