#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
// int main() {
// string s = "23232";
// double n = atof(s.c_str());
// //int n = atoi(s.c_str());
//
// cout << n << endl;
// }
//
// int main()
// {
// char*destination;
// float f=4.345;
// sprintf(destination,"%f",f);
// string te=f;
//
//
// cout<<te<<endl;
// return 0;
//}
string DoubleToString(double Input)
{
stringstream Oss;
Oss<<Input;
return Oss.str();
}
double StringToDouble(string Input)
{
double Result;
stringstream Oss;
Oss<<Input;
Oss>>Result;
return Result;
}
char * stringToLPCTSTR(string sFrom)
{
_TCHAR* sBuff = new _TCHAR[sFrom.length() + 2];
int iLength = 0;
iLength = wsprintf (sBuff,sFrom.c_str ());
sBuff[iLength+1] = '/0';
return sBuff;
}
int main()
{
double Str_1 = 12345.56789;
string Str_2 = "12345.56789";
cout<<"Double --> String"<<endl;
cout<<DoubleToString(Str_1)<<endl;
cout<<"String --> Double"<<endl;
cout<<StringToDouble(Str_2)<<endl;
system("pause");
}
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
// int main() {
// string s = "23232";
// double n = atof(s.c_str());
// //int n = atoi(s.c_str());
//
// cout << n << endl;
// }
//
// int main()
// {
// char*destination;
// float f=4.345;
// sprintf(destination,"%f",f);
// string te=f;
//
//
// cout<<te<<endl;
// return 0;
//}
string DoubleToString(double Input)
{
stringstream Oss;
Oss<<Input;
return Oss.str();
}
double StringToDouble(string Input)
{
double Result;
stringstream Oss;
Oss<<Input;
Oss>>Result;
return Result;
}
char * stringToLPCTSTR(string sFrom)
{
_TCHAR* sBuff = new _TCHAR[sFrom.length() + 2];
int iLength = 0;
iLength = wsprintf (sBuff,sFrom.c_str ());
sBuff[iLength+1] = '/0';
return sBuff;
}
int main()
{
double Str_1 = 12345.56789;
string Str_2 = "12345.56789";
cout<<"Double --> String"<<endl;
cout<<DoubleToString(Str_1)<<endl;
cout<<"String --> Double"<<endl;
cout<<StringToDouble(Str_2)<<endl;
system("pause");
}