char* GetDoubleStr(double value)
{
char buf[32]={0};//长度可以自定义
sprintf(buf,"%.8f",value);//保留8位小数,不够补0
int index = 0;
int len = strlen(buf);
for(int i = len-1;i>0;i--)
{
if(buf[i] == '0')
continue;
else
{
if(buf[i] == '.') index = i;
else index = i+1;
break;
}
}
buf[index] = '\0';
return buf;
}

  

C语言下double转char*或者std::string,可以精确转换不含多余的0的更多相关文章

  1. c++之常见数据类型(int,double,float,long double long long 与std::string之间)相互转换(含MFC的CString、含C++11新特性函数)

    --- 已经通过初步测试---- ------------------ 下面的是传统常见数据类型的转换(非c++11)---------------  std::string 与其他常用类型相互转换, ...

  2. java字符数组char[]和字符串String之间的转换

    java字符数组char[]和字符串String之间的转换 觉得有用的话,欢迎一起讨论相互学习~Follow Me 使用String.valueOf()将字符数组转换成字符串 void (){ cha ...

  3. std::string 字符串大小写转换(转)

    该问题归结为std::transform函数的使用 函数原型 template < class InputIterator, class OutputIterator, class UnaryO ...

  4. no matching function for call to ‘std::basic_string<char>::assign(std::string&, int)

    使用string中的assign赋值函数报错,代码为: text0.assign(line,i+); 其中text0与line都为string类型 最后发现assign函数的原型为 string &a ...

  5. C++ char float int string 之间的转换

    string str = "123"; string 转 int int i = atoi( str.c_str() ); string 转 float float f = ato ...

  6. QString, Std::string, char *相互转换

    Qt 库中对字符串类型进行了封装,QString 类提供了所有字符串操作方法,给开发带来了便利. 由于第三方库的类型基本上都是标准的类型,即使用std::string或char *来表示字符 (串) ...

  7. std::string 用法总结

    标准C++中的string类的用法总结 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果离开了MFC框架,还有 ...

  8. 类 this指针 const成员函数 std::string isbn() const {return bookNo;}

    转载:http://www.cnblogs.com/little-sjq/p/9fed5450f45316cf35f4b1c17f2f6361.html C++ Primer 第07章 类 7.1.2 ...

  9. CString 与 std::string 相互转化

    MFC中CString 与 std::string 相互转化 CString实际是CStringT, 也就是模板类, 在UNICODE环境下,实际是CStringW, 在多字符集环境下,实际是CStr ...

随机推荐

  1. (NO.00002)iOS游戏精灵战争雏形(二)

    在SpriteBuilder中新建Images文件夹,将所需要的图片素材全部拖入其中: 别忘了将其转换为智能精灵图表文件夹. 因为我们不需要为ipad和安卓设计,所以在项目设置里将所有出iphone以 ...

  2. (NO.00001)iOS游戏SpeedBoy Lite成形记(三十):增加排行榜功能3

    在这个例子中,我们的显示代码只需要选手的名字以及对应的成绩.根据选手名字取对应的成绩可以用前面实现的playerRecord:方法,我们只需要将按照成绩排序后的选手名字返回就可以了. 我只需要再实现一 ...

  3. SpriteBuilder中CCMotionStreak提示图片文件找不到

    今天写代码时遇到上述问题,代码如下: player.streak = [CCMotionStreak streakWithFade:3.f minSeg:1 width:30 color:[CCCol ...

  4. Android 自定义View -- 简约的折线图

    转载请注明出处:http://write.blog.csdn.net/postedit/50434634 接上篇 Android 圆形百分比(进度条) 自定义view 昨天分手了,不开心,来练练自定义 ...

  5. HTML的TextArea中保存格式的问题

    textarea在保存时格式是可以保存到数据库的,但是展示时因为/n和 不能互转导致页面不能按照刚开始的时候的格式展示,所以在页面展示的时候,要在值的外面嵌套一层 标签,即 < pre > ...

  6. 开发资源库(repositiory)

    1.. 52研发网MTK软件 2.一流研发 3. android+MTK/华为的源代码及资料库(CryToCry96) 点击打开链接 4.android+MTK/华为/联想的源代码及资料库(lucka ...

  7. saiku运行时报错max_length_for_sort_data 需要set higher

     infiniDB或者mysql数据库,运行时,按某个字段排序会出错.报错:max_length_for_sort_data  ... set higher. saiku报错, 也是这样. 这是数 ...

  8. ARC时代的内存管理

    什么是ARC Automatic Reference Counting (ARC) is a compiler feature that provides automatic memory manag ...

  9. 任务管理器中的PID找不到

    PID是Process ID的简称,这对WINDOWS开发人员来说是非常有用的信息,但对于普通用户来说则根本不必去理会.   举个例子来说: 在网站发布的时候,需要安装IIS,那么iis的tcp的80 ...

  10. Myeclipse Db Browser使用

    1.打开Myeclipse,选择菜单栏Window-->Show View-->Other,展开MyEclipse Database,选择DB Browser,打开数据库浏览视图 2. 空 ...