may be i should ask my question with details so here it is......
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<iostream>
usingnamespace std;
int main()
{
char x[]="29";
int num;
// and here should be the piece of code which will convert char data into int
?????????????????????????;
?????????????????????????;
//and the value of "char x" should be passed to "int num" without changing it
cout<<"the value of num is = "<<num;
return 0;
}
so the output should look like this.
the value of num is = 29
and also i would like to know how to do vice versa
thanks that worked but i still have one question (i am a noob)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include<iostream>
usingnamespace std;
int main()
{
char x[256];
int num=923;
//piece of code
??????????;
//finish
cout<<"the value of x is = "<<x;
return 0;
}
output
the value of x is = 923
i just want to convert a numerical char to int data.
Long long time ago I do some testing on some data volume and somewhow C++ stringstream class is very slow in comparison to say sprintf. The effect is only noticeable if say you want to do such conversion a million times perhaps ?