Hi Guys ,
I'm just working In a project and I need to convert integer value to a string variable < I've just tried all the functions that I know , and they all doesn't work , Please Help me in this ..
here is one of the codes that I've tried :
it gives this error :
error C2228: left of '.str' must have class/struct/union
and this warning :
warning C4552: '<<' : operator has no effect; expected operator with side-effect
I've tried "itoa" function and same thing..
Please Help :)
The to_string() function will require a newer version of your compiler, I suggest the latest version.
Your stringstream method should work properly, as long as you use the correct variable names. Remember C++ is case sensitive, Num is not the same as num. Something more like:
1 2 3 4 5 6 7 8 9 10
int num;
cin>>num;
string res;
stringstream convert;
convert << num;
res= convert.str();
cout << res << endl;