I wanna convert an integer to a character then i will store it later to the index of a c-string......
something like...
int res=123
then it will be putted in....
var[0] = 123
where in var is a cstring, and here 123 is now a char type.....
here is what ive tried...
#include<iostream>
using namespace std;
int main()
{
int res=123;
char buf[10];
itoa(res,buf,10);
cout<<"new char: "<<buf[0];
system("pause>0");
}
what happened is, only the 1 in 123 is being converted into char and stored to the cstring........
is there a way to avoid it? is the itoa function that i used is wrong? i found something on the net where the integer will be converted into string...... but i cant put the value of this string to the index of the cstring...
help please
what i want to achieve is for the whole buff[0] will contain the 123 value..... because ill gonna use it later in the arithmetic in stacks so that i can separate them when i do for example addition...............
buff[0] + buff[1]
= 123 + 54