C++ string long double转char*

long

long q = 10;
char s[8];
char* output;
sprintf(s, "%ld", q);
output = s;

 

double

double d = 10;
char
s1[8]; sprintf(s1, "%.2lf", d);

 

string

str.data();

 

 

%.后的数字为保留几位小数点

posted @ 2014-12-29 15:14  HONT  阅读(1413)  评论(0编辑  收藏  举报