Hakan Sözer

Yel Değirmenlerine Karşı Don Kişot Muyum?

c++ conversion between string , int , double

January11

#include <sstream>

//convert string to double

string str;
double number;
str = “16.2″
number = atof(str.c_str());

//convert double to string

result = 16.2;   string s;
std::ostringstream ss;
ss << result;
s = ss.str();

//convert int to string

i = 5;
string s;
std::stringstream out;
out << i;
s = out.str();

//convert string to int

string str;
double number;
str = “16″
number = atoi(str.c_str());

E-posta gizli kalacak.

Website örneği

Yorumunuz: