功能:把一个小数形式的字符串转化为一个浮点数。

案例

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(void)
{
    // 字符类型
    // char ch[] = " -123456abc"; 只会打印数字、非数字停止
    char ch[] = "-12.3456";
    // 转换类型
    double i = atof(ch);
    // 转换为double类型
    printf("%d\n", i);
    return 0;
}
atof 使用案例

相关文章:

  • 2021-08-21
  • 2022-12-23
  • 2021-12-20
  • 2021-12-19
  • 2021-09-18
  • 2022-01-02
  • 2022-12-23
  • 2021-06-11
猜你喜欢
  • 2021-08-05
  • 2022-12-23
  • 2021-06-27
  • 2021-09-26
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案