C/C++ atof函数 - C语言零基础入门教程
生活随笔
收集整理的這篇文章主要介紹了
C/C++ atof函数 - C语言零基础入门教程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
- 一.atof 函數簡介
- 二.atof 函數函數實戰
- 三.猜你喜歡
零基礎 C/C++ 學習路線推薦 : C/C++ 學習目錄 >> C 語言基礎入門
一.atof 函數簡介
在 stdlib.h 中 atof 函數,可用于將 char 字符串轉為 float / double 浮點數類型,語法如下:
/* *描述:將一個char類型轉為浮點數double * *參數: * [in] str:字符串類型 * *返回值:返回char類型對應的浮點數double */ double atof ( const char * str );二.atof 函數函數實戰
/******************************************************************************************/ //@Author:猿說編程 //@Blog(個人博客地址): www.codersrc.com //@File:C/C++ atof函數 //@Time:2021/08/15 08:00 //@Motto:不積跬步無以至千里,不積小流無以成江海,程序人生的精彩需要堅持不懈地積累! /******************************************************************************************/#include "stdafx.h" #include <stdio.h> #include "windows.h"#pragma warning(disable: 4996)int _tmain(int argc, _TCHAR* argv[]) {printf("atof函數計算結果 %f \n", atof("13456"));printf("atof函數計算結果 %f \n", atof("0"));printf("atof函數計算結果 %f \n", atof("789"));printf("atof函數計算結果 %f \n", atof("123.123"));printf("atof函數計算結果 %f \n", atof("-9"));system("pause");return 0; } /* 輸出: atof函數計算結果 13456.000000 atof函數計算結果 0.000000 atof函數計算結果 789.000000 atof函數計算結果 123.123000 atof函數計算結果 -9.000000 請按任意鍵繼續. . . */注意占位符的使用:
浮點是使用 %f 整數是使用 %d char字符是使用 %c char字符串是使用 %s三.猜你喜歡
未經允許不得轉載:猿說編程 ? C/C++ atof 函數
總結
以上是生活随笔為你收集整理的C/C++ atof函数 - C语言零基础入门教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql csdn 知乎_CSDN 怎
- 下一篇: 两个瓶子水怎样一样多_同事每天比我多睡两