atof.cpp

来自「在c环境下的对数据结构进行讲解,包含有例题及答案」· C++ 代码 · 共 22 行

CPP
22
字号
//atof.cpp
#include <stdlib.h>
#include <iostream.h>
#include <conio.h>
void main(void)
{
  float f;
  int integer;
  char *str = "12345.67";
  f = atof(str);
  cout<<"字符串"<<str<<"转换为"<<f<<"的数值\n";
  integer = atoi(str);
  cout<<"字符串"<<str<<"转换为"<<integer<<"的整数值\n";
  char *st="1.2E+13";
  f = atof(st);
  cout<<"字符串"<<st<<"转换为"<<f<<"的数值\n";
  char *ss="12.S11";
  f = atof(ss);
  cout<<"字符串"<<ss<<"转换为"<<f<<"的数值";
  getch();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?