hi,
i've got to integers, lets say 0 and 6, which i want to copy into an character array. how do i do this?
char copied[3];
//copied[0] should be 0
//copied[1] should be 6
//copied[2] should be '/0' - the terminating character.
any suggestions?
tom
This is a discussion on convert int to char within the C++ Programming forums, part of the General Programming Boards category; hi, i've got to integers, lets say 0 and 6, which i want to copy into an character array. how ...
hi,
i've got to integers, lets say 0 and 6, which i want to copy into an character array. how do i do this?
char copied[3];
//copied[0] should be 0
//copied[1] should be 6
//copied[2] should be '/0' - the terminating character.
any suggestions?
tom
Code:#include <iostream> #include <sstream> using namespace std; int main() { stringstream ss; int i=0; int j=6; char copied[3]; ss << i << j << '\0'; ss >> copied; cout << copied; return 0; }