What I want is the same result as the following program:
int main(){
char y = '3';
cout << y;
return 0;
}
But to first store the int
variable into a char
array as a char
variable.
The main body of my program is as follows:
int main(){
char x[9];
int y = 1;
x[5] = y;
cout << x[5];
return 0;
}
And there is nothing in the console. I tried also
int main(){
char x[9];
int y = 3;
char m = y;
x[5] = m;
cout << m << endl;
cout << x[5] << endl;
return 0;
}
But there's still nothing in the console. I looked at other answers and everyone said these two data types can be converted directly, I really wonder where I did wrong and what should I do to get the wanted result.